-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClock.java
More file actions
39 lines (32 loc) · 856 Bytes
/
Copy pathClock.java
File metadata and controls
39 lines (32 loc) · 856 Bytes
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
package com.example.clock;
public class Clock {
public int time;
public void setTime(int a){
time = a;
}
public void tick(){
time = time + 1;
}
public void displayTime(){
System.out.println(time % 60);
}
public static void main(String[] args) {
Clock tester = new Clock();
// should display the time to be 56, 57, 58, 59, 0, 1, etc.
tester.setTime(56);
tester.tick();
tester.displayTime();
tester.tick();
tester.displayTime();
tester.tick();
tester.displayTime();
tester.tick();
tester.displayTime();
tester.tick();
tester.displayTime();
tester.tick();
tester.displayTime();
tester.tick();
tester.displayTime();
}
}