The Date Class

The MyDate class. Design a class named MyDate. The class contains:

  • The data fields year, month, and day that represents a date. Month is 0-based, i.e., 0 is for January.
  • A no-arg constructor that creates a MyDate object for the current date.
  • A constructor that constructs a MyDate object with a specified elapsed time since midnight, January 1,1970, in milliseconds.
  • A constructor that constructs a MyDate object with the specified year, month, and day.
  • Three get methods for the data fields year, month, and day, respectively.
  • A method named setDate(long elapsedTime) that sets a new date for the object using the elapsed time.

Draw the UML diagram for the class and then implement the class. Write a test program that creates two MyDate objects (using new MyDate() and new MyDate(3455555133101L) and display their year, month, and day.

Hint: The first two constructors will extract the year, month, and day from the elapsed time. For example, if the elapsed time is 561555550000 milliseconds, the year is 1987, the month is 9, and the day is 18. You may use the GregorianCalendar class discussed in Programming Exercise 8.5 to simplify coding.

The Person Class

The Person, Student, Employee, Faculty, and Staff classes. Design a class named Person and its two subclasses named Student and Employee. Make Faculty ad Staff subclass of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, and senior). Define the status as a constant. An employee has an ofice, salary, and date hired. Use the MyDate class defined in Programming Exercise 10.14 to create an object for date hired. A Faculty member has office hours and rank. A staff member has a title. Override the toString method in each class to display the class name and person's name.

Draw the UML diagram for the classes and implement them. Write a test program that creates a Person, Student, Employee, Faculty, and Staff, and invokes their toString() methods.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.