simpledate.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 52 行

JAVA
52
字号
package Entities;

/**	A simple class that represents a date */
public class SimpleDate implements Cloneable
{

	public SimpleDate(int nDay, int nMonth, int nYear)
	{
		day = nDay;
		month = nMonth;
		year = nYear;
	}
		
	public  int day;
	public  int month;
	public  int year;
	
	public void incDay()
	{
		if (day < 30)
			day++;
		else
		{
			day  = 1;
			if (month < 12)
				month++;
			else
			{
				month = 1;
				year++;
			}
		}
	}
	
	/**	A method which return the clone of the Shape <br>
		Analysis : Time = O(1) */
	public Object clone()
	{
		try
		{
			return super.clone();
		}catch (CloneNotSupportedException s) {}
		return this;
	}
	
	public  String toString()
	{
		return (day + "/" + month + "/" + year);
	}

} /* end of SimpleDate */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?