Answered step by step
Verified Expert Solution
Question
1 Approved Answer
clocks In this assignment you will work with an array of objects (Clock in this case). You will perform basic operations on the array including
clocks
In this assignment you will work with an array of objects (Clock in this case). You will perform basic operations on the array including sorting, searching, retrieving and modifying. You will also get a chance to work with input files and output files. The assignment will require you to write a Clock class, a ClockShop class, and work with an existing class (ClockShopTester) to test the functionality of your ClockShop and Clock classes. Details for each class are given below. Clock Include the following methods in your Clock class Clock(int the Hour, int the Minute, int the Second): Explicit value (parameterized) constructor that is passed the hour, minute, and second of the clock (all type int). Use the set methods specified below to ensure the passed in values are in the proper range Clock(): Default value constructor which defaults to 23:58:00 (two minutes to midnight). This constructor should call the explicit value constructor (via this) and let it do the work. .toString() override-- the method will return a String with the hours, minutes and seconds as follows: hh:mm:ss (ex: 9:49:59) getHour(), getMinute(), and getSecond() which return the appropriate value .setHour(int the Hour) -- set the current hour o if a value is outside the acceptable range of O through 23, throw an IllegalArgumentException that includes information about the incorrect value setMinute(int theMinute) set the current minute o if a value is outside the acceptable range of O through 59, throw an IllegalArgumentException that includes information about the incorrect value setSecond(int the Second) set the current second o if a value is outside the acceptable range of O through 59, throw an IllegalArgumentException that includes information about the incorrect value advanceHour(int theAmount): advance the current hour (a number 0 or greater will be passed in to the object from outside -- the resulting hour should be represented in the range of 0 to 23) (HINT: % is your friend) (any value less than O should throw an exception with an appropriate message) advanceMinute(int theAmount): advance the current minute (a number 0 or greater will be passed in to the object from outside -- the resulting minute should be represented in the range of 0 to 59 *AND* the hour should be updated accordingly) (any value less than 0 should throw an exception with an appropriate message) equals(Object theObject) override -- compare against another Clock object for equality. Once this method confirms the parameter is not null and is a Clock, it should call the compareto method specified below compareTo(Clock theOtherClock) -- implement the Comparable interface and write the associated compareTo method so that the current Clock can be compared against another Clock for order. Your Clock class should have implements ComparableStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started