Lab 11-21 (1) Class Definition
Lab 11-21 (1) Class Definition
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 = "Jan";
day = 1;
}
}
public class DateFirstTryDemo
{
public static void main(String[] args)
{
DateFirstTry Date1;
Date1 = new DateFirstTry();
Date1.month = "Dec";
Date1.day = 31;
Date1.year = 2006;
System.out.println("Date:");
Date1.writeoutput();
System.out.println("The Date change to:");
Date1.makeItNewYear();
Date1.writeoutput();
}
}

0 Comments:
張貼留言
<< Home