-
Notifications
You must be signed in to change notification settings - Fork 1
/
Timer.java
65 lines (58 loc) · 1.26 KB
/
Timer.java
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* This class handles in-game timers.
* timer - the current value of the timer
* update - what to change the update time with
* low - when to return that the timer is being low
*/
public class Timer {
private int timer;
private int update;
private int low;
public Timer(int defaultTime, int defaultUpdate, int defaultLow) {
timer = defaultTime;
update = defaultUpdate;
low = defaultLow;
}
/**
* prints out the timer.
*/
public String toString() {
return Integer.toString(timer);
}
/**
* updates the timer
*/
public void updateTimer() {
timer += update;
}
/**
* alter timer data
*/
public void setTime(int time) {
timer = time;
}
public void setUpdate(int update) {
this.update = update;
}
public void setLow(int low) {
this.low = low;
}
/**
* check if the timer is low
*/
public boolean isLow() {
if (timer <= low) {
return true;
}
return false;
}
/**
* check if the timer reached zero
*/
public boolean hasExpired() {
if (timer <= 0) {
return true;
}
return false;
}
}