JAVA这道题什么地方需要修改

来源:百度知道 编辑:UC知道 时间:2024/05/17 01:45:12
public class Exam3_6
{
private int year,month,day;
Exam3_6
{
year=2000;
month=1;
day=1;
}
Exam3_6(int a,int b,int c)
{
year=a;
month=b;
day=c;
}
Exam3_6(Exam3_6 d)
{
year=d.year;
month=d.month;
day=d.day;
}
public void outDate()
{
System.out.print(year+"/"+month+"/"+day);
}
public Exam3_6 tomorrow()
{
Exam3_6 d=new Exam3_6(this);
d.day++;
if(d.day>d.daysInMonth())
{
d.day=1;
d.month++;
if(d.month>12)
{
d.month=1;
d.year++;
}
}
return d;
}
public int daysInMonth()
{
switch(month)
{
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
return 31;
case 4: case 6: case 9: case 11:
return 30;
default:
if(year%4==0&&year%100!=0||year%400==0)
return 29;
els

也没有这么多错误,也就一个错误

下面:

public class Exam3_6{

private int year,month,day;

Exam3_6(){
year=2000;
month=1;
day=1;
}

Exam3_6(int a,int b,int c){
year=a;
month=b;
day=c;
}

Exam3_6(Exam3_6 d){
year=d.year;
month=d.month;
day=d.day;
}

public void outDate(){
System.out.print(year+"/"+month+"/"+day);
}

public Exam3_6 tomorrow(){
Exam3_6 d=new Exam3_6(this);
d.day++;
if(d.day>d.daysInMonth()){
d.day=1;
d.month++;
if(d.month>12)
{
d.month=1;
d.year++;
}
}
return d;
}
public int daysInMonth(){
switch(month){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
return 31;
case 4: case 6: case 9: case 11: