Question: Write a class called Time that includes five fields: year, month, day, minutes and seconds. This class stores information about a single point in time.

Write a class called Time that includes five fields: year, month, day, minutes and seconds. This class stores information about a single point in time. Your class should have constructor(s), accessors and mutators, and it should implement the Comparable interface. Years take precedence over months, which take precedence over days etc. For example, Feb 19, 2016 comes after Nov 20, 2015.

Write a client class TimeTest that creates 3 instances of class Time, initializes them with random values (you can specify the values yourself or use Math.random() function), adds them to ArrayList and sorts the list (you can use Collections.sort()).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!