Define a base class to represent a Clock.

Your class should have instance variables for hours,
minutes and seconds.


```
public class Clock
{
private int hour;
private int minute;
private int second;
public Clock()
{
//initialize to default values
hour = 0;
minute = 0;
second = 0;
}
public Clock(int h, int m, int s)
{
setHour(h);
setMinute(m);
setSecond(s);
}
/**
Valid integers for hour is in the range of 0 - 24
*/
public void setHour(int h)
{
if((h >= 0) && (h <= 24))
hour = h;
else
System.out.println("Fatal error: invalid hour");
}
/**
Valid integers for minute is in the range 0 - 59
*/
public void setMinute(int m)
{
if((m >= 0) && (m <= 59))
minute = m;
else
System.out.println("Fatal error: invalid minute");
}
/**
Valid integers for second is in the range 0 - 59
*/
public void setSecond(int s)
{
if((s >= 0) && (s <= 59))
second = s;
else
System.out.println("Fatal error: invalid second");
}
public int getHour()
{
return hour;
}
public int getMinute()
{
return minute;
}
public int getSecond()
{
return second;
}
//Facilitator methods
public String toString()
{
return "The current time is: " + hour + ":" + minute + ":" + second;
}
public boolean equals(Object o)
{
if(o == null)
return false;
else if(getClass() != o.getClass())
return false;
else
{
Clock otherClock = (Clock) o;
return((hour == otherClock.hour) && (minute == otherClock.minute)
&& (second == otherClock.second));
}
}
}

```

Computer Science & Information Technology

You might also like to view...

The ________ bar displays information such as the size of the slide, the viewing percentage, the number of slides in the presentation, and the type of view currently being used

A) Information B) Status C) Menu D) Title

Computer Science & Information Technology

Third-party authorization and masquerading are examples of computer-based social engineering attacks

Indicate whether the statement is true or false.

Computer Science & Information Technology

On a(n) ____________________ webpage, the content changes only when a web developer updates the HTML code for each page.?

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Critical Thinking Questions 11-1 ? Lisa and her team have finished the coding of a new application, and they are ready to begin testing. She asks Tina, a senior software tester, for help in designing the types of tests that Lisa and her team should perform. Tina also recommends that Lisa test groups of programs that depend on each other to confirm that they work together correctly. What is one of the names of this type of testing?

A. Integration testing B. System testing C. Unit testing D. Stub testing

Computer Science & Information Technology