GameNCode

Date Constructor

Feb 3rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. /**
  2. * Created by Roy Weisfeld on 2/3/2017.
  3. */
  4. public class Date {
  5. private int day;
  6. private int month;
  7. private int year;
  8. public Date(int day, int month, int year)
  9. {
  10.  
  11. }
  12.  
  13. public int getDay() {
  14. return day;
  15. }
  16.  
  17. public void setDay(int day) {
  18. this.day = day;
  19. }
  20.  
  21. public int getMonth() {
  22. return month;
  23. }
  24.  
  25. public void setMonth(int month) {
  26. this.month = month;
  27. }
  28.  
  29. public int getYear() {
  30. return year;
  31. }
  32.  
  33. public void setYear(int year) {
  34. this.year = year;
  35. }
  36.  
  37. public String toString()
  38. {
  39. return day + " / " + month + " / " + year;
  40. }
  41.  
  42. public void updateTomorrow()
  43. {
  44. if(day <= 30) {
  45. this.day++;
  46. }
  47. else if(month <= 12){
  48. this.month++;
  49. this.day = 1;
  50. }
  51. else{
  52. this.year++;
  53. this.month = 1;
  54. this.day = 1;
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment