-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_4_12.java
More file actions
45 lines (35 loc) · 1.44 KB
/
Example_4_12.java
File metadata and controls
45 lines (35 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package unit_04.Examples.Example_12;
import java.util.Scanner;
public class Example_4_12 {
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
Clock myClock = new Clock(5, 4, 30);
Clock yourClock = new Clock();
int hours, minutes, seconds;
System.out.println("> My Clock: " + myClock);
System.out.println("> Your Clock: " + yourClock);
yourClock.setTime(5, 45, 16);
System.out.println(">> After setting time for Your Clock: " + yourClock);
if(myClock.equals(yourClock)){
System.out.println("Both times are equal!");
}else{
System.out.println("The two times are not equal!");
}
System.out.println("Enter a Time: ");
System.out.println("Enter hour: ");
hours = scanner.nextInt();
System.out.println("Enter minute: ");
minutes = scanner.nextInt();
System.out.println("Enter second: ");
seconds = scanner.nextInt();
System.out.println();
myClock.setTime(hours, minutes, seconds);
System.out.println(">> New times of my clock: " + myClock);
myClock.incrementSeconds();
System.out.println(">>> After incrementing the clock by one second" +
", My clock : " + myClock);
yourClock.makeCopy(myClock);
System.out.println("After copying my clock into your clock: "
+ yourClock);
}
}