Question
class ExtClock extends Clock { private String timeZone; public ExtClock() { setTime(0, 0, 0, unknown); } public ExtClock(int hours, int minutes, int seconds, String zone)
class ExtClock extends Clock { private String timeZone;
public ExtClock() { setTime(0, 0, 0, "unknown"); } public ExtClock(int hours, int minutes, int seconds, String zone) { super(hours, minutes, seconds); timeZone = zone; } public void setTime(int hours, int minutes, int seconds, String zone) { timeZone = zone; }
public void setTimeZone(String zone) { timeZone = zone; } public String getTimeZone() { return timeZone; } @Override public String toString() { return (super.toString() + " " + timeZone); } }//end of class
public class TestClock { public static void main(String[] args) { ExtClock clockOne = new ExtClock(7, 30, 22, "Mountain"); ExtClock clockTwo = new ExtClock(); ExtClock clockThree = new ExtClock(14, 7, 35, "Central"); ExtClock clockFour = new ExtClock(); System.out.println(clockOne); System.out.println(clockTwo); System.out.println(clockThree); System.out.println(clockFour); }//end of main }//end of class
can not get the time to print correctly i get
ExtClock@15db9742 Mountain ExtClock@6d06d69c unknown ExtClock@7852e922 Central ExtClock@4e25154f unknown
Step 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