Advertisement
Yuvalxp8

Date Constructor

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