Question: Please help me with the java. 1. Define a derived class, AlarmClock , to represent an alarm clock, with the following Clock class as its
Please help me with the java.
1.Define a derived class, AlarmClock, to represent an alarm clock, with the following Clock class as its base class.
public class Clock {
private int hour;
private int minute;
private int second;
//default constructor
public Clock() {
//initialize to default values
hour = 0;
minute = 0;
second = 0;
}
//constructor with arguments
public Clock(int h, int m, int s) //set current time
{
hour = h;
minute = m;
second = s;
}
}
a. In your AlarmClock subclass, you only need to consider the following two aspects:
The AlarmClock should have three instance variables: alarmHour, alarmMinute, and alarmSecond.
b. Please write two constructors of the derived class AlarmClock -- one is the default constructor that assigns all member/instance variables to zero. The other takes 6 arguments time (ie., hour, minute, second, alarmHour, alarmMinute, alarmMinute.) that sets current time and alarm
(no need to write any other methods)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
