Reference no: EM133214605
Using a class template for the following class:
Class Name: Clock Fields: Hour, Minutes, Seconds
You should be able to infer the data types required for each of the fields. Your code should include the following in the template:
Fields.
Default Constructor.
Non-Default Constructor.
Accessor Methods for each field.
Mutator Methods for each field.
A display() method that displays the value of the fields on the screen.
A method called showTime(), which displays the time in the format hh:mm:ss.
The class header and the main() method have been already provided to you.
public class Clock
{
class Clock {
int hour;
int min;
int sec;
public static void main(String[] args)
{
Clock objClock = new Clock();
objClock.showTime();
}
void show_time()
{
System.out.println(hour + ":" + min + ":" + sec);
}
}