Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please answer the code using java and use the following class clock 4. We already designed the class Clock to implement the time of day
please answer the code using java and use the following class clock
4. We already designed the class Clock to implement the time of day in a program. We mentioned in lecture that certain applications, in addition to hours, minutes, and seconds, might require us to store the time zone. Derive the class ExtClock from the class Clock by adding a data member to store the time zone. Add the necessary methods and constructors to make the class functional. Also, write the definitions of the methods and the constructors. Write a test program to test your ExtClock class. The class ExtClock should contain the following methods and data member: static String array data member with values: EST, CST, MST, PST, EDT, CDT, MDT, PDT zone data member default constructor constructor with parameters setZone(x) getZonel) printTime() toString() equals(x) makeCopy(x) getCopy) 1/Method to increment the time by 1 second, 1/Postcondition: Time is incremented by 1 second, //If the before-increment time is 23:59:59, the time 1/is reset to 00:00:00. public void increment Seconds() { sec++; l/increment the value of sec by 1 if (sec > 59) 1/if sec is greater than 59 { sec = 0; //set sec to O increment Minutes(); //increment min } } //Method to increment the time by 1 hour. //Postcondition: Time is incremented by 1 hour. //If the before-increment time is 23:45:53, the time //is reset to 00:45:53. public void increment Hours() { hr++; //increment the value of hr by 1 if (ht > 23) //if hr is greater than 23, hr = 0; //set hr to O } //Method to print the time. //Postcondition: Time is printed in the ll form hh:mm:ss. public void print Time() { if (hr We'll use this method to paint Clock objects in form hromin: sec if (minStep 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