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
3.40 Rating (156 Votes )
There are 3 Steps involved in it
To solve this problem well define the Time class as specified ensuring it implements the Comparable interface for sorting purposes Then well create a TimeTest client class to demonstrate the functiona... View full answer
Get step-by-step solutions from verified subject matter experts
