123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- class Calendar extends Date
- {
-
- public Calendar(int d,int m,int y) throws DateException
- {
- super(d,m,y);
- }
-
- public void addDay()
- {
- day++;
- if(day==32)
- {
- day=1;
- month++;
- }
- else if(day==31&&(month==4||month==6||month==9||month==11))
- {
- day=1;
- month++;
- }
- else if(day==30&&month==2)
- {
- day=1;
- month=3;
- }
- else if(day==29&&month==2&&year%4!=0)
- {
- day=1;
- month=3;
- }
- if(month==13)
- {
- month=1;
- year++;
- }
- }
-
- public void subDay()
- {
- day--;
- if(day==0)
- {
- month--;
- if(month==0)
- {
- month=12;
- day=31;
- year--;
- }
- else if(month==4||month==6||month==9||month==11)
- day=30;
- else if(month==2)
- if(year%4==0)
- day=29;
- else
- day=28;
- else
- day=31;
- }
- }
-
- public void addMonth()
- {
- month++;
- if(month==13)
- {
- month=1;
- year++;
- }
- else if(day==31&&(month==4||month==6||month==9||month==11))
- day=30;
- else if(month==2)
- if(year%4==0)
- {
- if(day>29)
- day=29;
- }
- else if(day>28)
- day=28;
- }
-
- public void subMonth()
- {
- month--;
- if(month==0)
- {
- month=12;
- year--;
- }
- else if(day==31&&(month==4||month==6||month==9||month==11))
- day=30;
- else if(month==2)
- if(year%4==0)
- {
- if(day>29)
- day=29;
- }
- else if(day>28)
- day=28;
- }
-
- public void addYear()
- {
- year++;
- if(month==2&&day==29)
- day=28;
- }
-
- public void subYear()
- {
- year--;
- if(month==2&&day==29)
- day=28;
- }
-
- }
-
|