You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
971 B

  1. package de.hs_fulda.ciip.projjpn;
  2. public class Birthdate {
  3. private int day;
  4. private int month;
  5. private int year;
  6. public Birthdate(int d, int m, int y) {
  7. day = d;
  8. month = m;
  9. year = y;
  10. }
  11. public int getDay() {
  12. return day;
  13. }
  14. public int getMonth() {
  15. return month;
  16. }
  17. public int getYear() {
  18. return year;
  19. }
  20. /**
  21. * @return Date Format DD.MM.YYYY
  22. */
  23. public String toString() {
  24. return day + "." + month + "." + year;
  25. }
  26. /**
  27. *
  28. * @param d Day
  29. * @param m Month
  30. * @param y Year
  31. */
  32. public void changeBirthdate(int d, int m, int y) {
  33. day = d;
  34. month = m;
  35. year = y;
  36. }
  37. /**
  38. *
  39. * @param DD
  40. * @param MM
  41. * @param YYYY
  42. * @return true if date is valid.
  43. * @return false if date is invalid.
  44. */
  45. public boolean isValid(int DD, int MM, int YYYY) {
  46. if (DD < 1 || DD > 31) {
  47. return false;
  48. }
  49. if (MM < 1 || MM > 12) {
  50. return false;
  51. }
  52. if (YYYY < 1990 || YYYY > 2022) {
  53. return false;
  54. }
  55. return true;
  56. }
  57. }