English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

class Date{

int day, month, year, dayOfweek;

public static int[] daysInMonth ={31,28,30,30,31,30,31,31,30,31,30,31};
public static String[] MonName = {"January", "February", "March", "April", "May", "June",

"July", "August", "September", "October", "November", "December"};
public static String[] dayName = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",

"Friday", "Saturday"};

public static Boolean isLeap(int year ){
if(year % 400 == 0)
return true;

if(year % 100 == 0 || year % 4 !=0)
return false;

return true;
}

Date(int d, int m, int y){
day = d-1;
month = m-1;
year = y;
dayOfweek=-1;
}

Date(int d, int m, int y, int w){

day = d-1;
month = m-1;
year = y;
dayOfweek =w;

}

public void next(){

if( isLeap( year ))
daysInMonth[1] = 29;

else
daysInMonth[1] = 28;

day++;

if(day == daysInMonth[month]){

day = 0;
month++;
}
if (month == 12){
month = 1;
year++;
}
dayOfweek++;
dayOfweek%=7;
}
public void print(){

System.out.println(MonName[month] + " " + (day+1) + "is a" + dayName[dayOfweek]);
}
public int compare(Date target){
if( year < target.year )
return 1;

if(year < target.year)
return -1;

if(month < target.month)
return -1;

if(month > target.month)
return -1;

if( day < target.day)
return 1;

if(day > target.day)
return -1;

return 0;
}

}

2007-02-27 03:36:58 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

Where is your main method to run the program ?

2007-02-27 04:24:08 · answer #1 · answered by BK 2 · 0 0

It's possible you compiled your Date class and main class file at different times. Make sure they both still compile. The compiler should point you to the missing method.

2007-02-27 04:41:12 · answer #2 · answered by scruffy 5 · 0 0

fedest.com, questions and answers