2008年4月14日 星期一

Display4.1+ makeItNewYear

public class DateFirstTry
{
public String month;
public int day;
public int year;
public void writeOutput()
{
System.out.println(month+" "+day+","+year);
}
public void makeItNewYear()
{
month = "January";
day = 1 ;
}
}


public class DateFirstTryDemo
{
public static void main(String[] args)
{
DateFirstTry date1,date2;
date1 = new DateFirstTry();
date2 = new DateFirstTry();
date1.month = "December";
date1.day = 31;
date1.year = 2007;
System.out.println("date1:");
date1.writeOutput();

date1.makeItNewYear();
System.out.println("new date1:");
date1.writeOutput();

date2.month = "July";
date2.day = 4;
date2.year = 1776;
System.out.println("date2:");
date2.writeOutput();

date2.makeItNewYear();
System.out.println("new date2:");
date2.writeOutput();
}
}

結果:

沒有留言: