Free University of Bolzano/Bozen
Faculty of Computer Science - Bachelor in Applied Computer Science
Bachelor in Production Engineering
Introduction to Programming - A.A. 2004/2005

Exercise
Class Date

Part 1: Design and realize a Java class Date to represent dates. The following functionalities are of interest for dates:

Add to the class also a method that does overriding of toString inherited from Object in such a way that it returns a string representing a date in a suitable way.

Part 2: Write a static method, external to the class Date that, given a Date as a parameter, returns the date of the following day.

Part 3: Write a client that makes use of the class Date as follows:

  1. It creates two dates, by reading day, month, and year from the keyboard, and prints them.
  2. It calculates the date of the day following the second date, and prints it.
  3. It prints a suitable messagge depending on whether the two dates are equal, the first one precedes the second one, or the second one precedes the first one.