Month Class

/**
 *A month has a number that corresponds to a month of the year.
 */
public class Month
{
	private int monthNum;
	
	public Month()
	{
		this(0);
	}
	
	public Month(int newMonthNum)
	{
		monthNum=newMonthNum;
	}
	
	public String getMonth()
	{
		String months="January  February March    April    May      "+
		"June     July     August   SeptemberOctober  November December ";
		return months.substring(9*(monthNum-1),9*(monthNum-1)+9).trim();
	}
	
	public String toString()
	{
		return monthNum+" corresponds to "+getMonth()+".";
	}
}

/**
Enter the number of the month: 3
3 corresponds to March.
Press any key to continue...
*/



Home
Site hosted by Angelfire.com: Build your free website today!