Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Work out the following programming exercise 1 from Chapter 11 1. In Chapter 8, the class Clock was designed to implement the time of day

Work out the following programming exercise 1 from Chapter 11

1. In Chapter 8, the class Clock was designed to implement the time of day in a program. Certain applications in addition to hours, minutes, and seconds, might require you 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. Finally, write a test program to test your class.

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

C:\Users\Dracatas\Documents\NetBeansProjects\ClassClock\src\TestClock.java:1: error: cannot find symbol class ExtClock extends Clock symbol: class Clock C:\Users\Dracatas\Documents\NetBeansProjects\ClassClock\src\TestClock.java:29: error: method does not override or implement a method from a supertype @Override C:\Users\Dracatas\Documents\NetBeansProjects\ClassClock\src\TestClock.java:32: error: cannot find symbol return (super.toString() + " " + timeZone); symbol: variable super location: class ExtClock 3 errors C:\Users\Dracatas\Documents\NetBeansProjects\ClassClock bproject\build-impl.xml:930: The following error occurred while executing this line: C:\Users\Dracatas\Documents\NetBeansProjects\ClassClock bproject\build-impl.xml:270: Compile failed; see the compiler error output for details. BUILD FAILED (total time: 1 second)

i am still learning java so i am not 100% sure or what to change or where to change it at

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago