Question
public class ExtClock extends Clock { private String timeZone; public ExtClock() { setTime(0, 0, 0, unknown); } public ExtClock(int hours, int minutes, int seconds, String
public 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) { // I think something should go here to represent // the hours, minutes, and seconds... 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) { //instantiate a few ExtClock objects ExtClock clockOne = new ExtClock(7, 30, 22, "Mountain"); ExtClock clockTwo = new ExtClock();//tests default constructor ExtClock clockThree = new ExtClock(14, 7, 35, "Central"); //test methods on ExtClock objects ? //print out the values of the ExtClock objects System.out.println(clockOne); System.out.println(clockTwo); System.out.println(clockThree); }//end of main }//end of class
ExtClock.java:36: error: class TestClock is public, should be declared in a file named TestClock.java public class TestClock ^ Clock.java:1: error: class ExtClock is public, should be declared in a file named ExtClock.java public class ExtClock extends Clock ^ Clock.java:36: error: class TestClock is public, should be declared in a file named TestClock.java public class TestClock ^ ExtClock.java:1: error: cannot access Clock public class ExtClock extends Clock ^ bad source file: .\Clock.java file does not contain class C
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