Advertisement
Voldemord

[Java] Calendar

Apr 4th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. package zadanie5;
  2.  
  3. /**
  4.  *
  5.  * @author Student
  6.  */
  7. public class Calendar {
  8.     private int year;
  9.     private int mounth;
  10.     private int day;
  11.    
  12.     public Calendar(int day, int mounth, int year) throws Exception{
  13.        
  14.         if(mounth < 1 || mounth > 12)
  15.             throw new Exception("Date problem - mounth");
  16.         if(((year == 0 || year % 4 == 0) && day > 29) || ((year != 0 || year % 4 != 0) && day > 28) )
  17.             throw new Exception("Date problem - mounth - February");
  18.        
  19.         this.year = year;
  20.         this.mounth = mounth;
  21.         this.day = day;
  22.        
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement