为什么这个java程序运行不出结果啊?
classMydate{privateintyear,month,day;publicStringgetDate(){returnyear+"/"+month+"/"+d...
class Mydate {
private int year,month,day;
public String getDate()
{
return year+"/"+month+"/"+day;
}
public int setDate(int y,int m,int d)
{
if((month>0&&month<=12)&&(day>0&&day<=31))
{
year=y;
month=m;
day=d;
return 0;
}
else{
return 1;
}
}
}
public class TestMyDate {
public static void main(String[] args)
{
Mydate d=new Mydate();
if(d.setDate(2011, 11, 5)==0)
System.out.println(d.getDate());
}
} 展开
private int year,month,day;
public String getDate()
{
return year+"/"+month+"/"+day;
}
public int setDate(int y,int m,int d)
{
if((month>0&&month<=12)&&(day>0&&day<=31))
{
year=y;
month=m;
day=d;
return 0;
}
else{
return 1;
}
}
}
public class TestMyDate {
public static void main(String[] args)
{
Mydate d=new Mydate();
if(d.setDate(2011, 11, 5)==0)
System.out.println(d.getDate());
}
} 展开
1个回答
展开全部
class Mydate {
private int year, month, day;
public String getDate() {
return year + "/" + month + "/" + day;
}
public int setDate(int y, int m, int d) {
if ((m > 0 && m <= 12) && (d > 0 && d <= 31)) {
year = y;
month = m;
day = d;
return 0;
} else {
return 1;
}
}
}
public class TestMyDate {
public static void main(String[] args) {
Mydate d = new Mydate();
if (d.setDate(2011, 11, 5) == 0)
System.out.println(d.getDate());
}
}
private int year, month, day;
public String getDate() {
return year + "/" + month + "/" + day;
}
public int setDate(int y, int m, int d) {
if ((m > 0 && m <= 12) && (d > 0 && d <= 31)) {
year = y;
month = m;
day = d;
return 0;
} else {
return 1;
}
}
}
public class TestMyDate {
public static void main(String[] args) {
Mydate d = new Mydate();
if (d.setDate(2011, 11, 5) == 0)
System.out.println(d.getDate());
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询