JAVA PROGRAM
1. Modify the program so that the hour value is between
0-23, minutes 0-59, and seconds 0-59. (Capture the
result)
2. Explain how abstraction and encapsulation are
applied to Clock Class based on point 1.
public class Clock
{
private int hour=0;
private int minute=0;
private int second=0;
public void addhour()
{
hour++;
}
public void addminute()
{
minutes++;
}
public void addsecond()
{
seconds++;
}
public void displayClock()
{
System.out.printf("%2d:%2d:%2d", hour, minute,
second);System.out.println();
}
public static void main(String[] args)
{
Clock1 = new Clock();
Clock1.displayClock();
Clock1.addClock();
Clock1.displayClock();
}
}
JAVA PROGRAM 1. Modify the program so that the hour value is between 0-23, minutes 0-59, and seconds 0-59. (Capture the
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
JAVA PROGRAM 1. Modify the program so that the hour value is between 0-23, minutes 0-59, and seconds 0-59. (Capture the
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!