CS1120 Spring 2007
Instructor: Zille Huma Kamal
Worksheet I
January 9, 2007
Name:________________________________________________________
Develop a class called Date with the following members
and methods:
- private data members: day, month, year
- properties for each private data member
- methods:
- A print method that prints the date in traditional
format – “09/06/06”
- A print method that prints the date in the
following format – “Today is 6th day of September in the year
2006”
- A set date method, which takes 3 arguments, day,
month and year and assigns them to the data members
- 2 constructors:
a
default constructor – that sets the date to October 1 1979
an
overloaded constructor that takes 3 arguments, and assigns them to the day,
month and year data members
Develop a class called TestDate which does the following:
- Create three Date
objects, and initialize them as follows:
- Default date object
- A date object with the following date: 04/29/04
- And a data object with the following date: June 18th 2006
- Print the objects
- Ask the user for a date, and create a new date object
that represents the user given date.
- Print the date object of (6).
Final test
- Open the test
file, read the Dates
and store them in a Date array.
File Format mm/dd/yyyy.
- Sort the entries in the array in ascending order and
print them.