Name ____________________                                                           Lab 9 Deliverable

 

Part I:  no deliverable but should be tested to make sure it works

 

Part II:  Do steps 1..4   then answer the question below in the box provided

        What happens when you execute your driver?

2 JMU clocks appear – one says Harrisonburg or home , one says Paris – each shows current time of day at location specified.

 

Do steps 5..8, then answer the question below in the box provided

                What happens when you execute your driver?

clock is updated and beeps once when set time occurs

 

Answer the question in step 9 in the box below

we don’t see time on AlarmClock face

 

Part III: Carefully read each the code for each of the TesterX.java files.  Do them one at a time.  After studying each (and compiling each to verify your understanding) write the answer to the question  Will this class compile?  (yes/no)  in the left part of each box and the answer to  If so, why?   If not, why not?  (why? or why not?) in the right part of each box.  Turn this in at the start of lab on Monday.

Tester1

yes

An AlarmClock is-a  Clock.  AlarmClock objects inherit Clock attributes because AlarmClock extends the Clock class (note that both clocks reverse colors)

 

Tester2

no

Clock object can’t call turnAlarmOn()

¼§ÏTester2.java:28: cannot find symbol
ϧÏsymbol  : method turnAlarmOn()
ϧÏlocation: class Clock
ϧÏclock.turnAlarmOn();

 

Tester 3

no

can’t pass a Clock object when an AlarmClock is needed (a Clock is NOT an AlarmClock) 

¼§ÏTester3.java:18: setup(AlarmClock) in Tester3 cannot be applied to (Clock)

 

Tester 4

yes

An AlarmClock object inherits the attributes of Clock and therefore can be assigned to a Clock object

 

Tester 5

no

can’t call SetAlarm on a Clock object

 ¼§ÏTester5.java:16: cannot find symbol
ÏϧÏsymbol  : method setAlarm(int,int,int,java.lang.String)
ÏϧÏlocation: class Clock
ÏϧÏhome.setAlarm(1, 39, 45, "PM");
ÏϧϠ   ^
ϼ§ÏTester5.java:17: cannot find symbol
ÏϧÏsymbol  : method turnAlarmOn()
ÏϧÏlocation: class Clock
ÏϧÏhome.turnAlarmOn();
ÏϧϠ   ^ Ï

  §Ï2 errors