-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeableLight.java
More file actions
91 lines (68 loc) · 1.74 KB
/
TimeableLight.java
File metadata and controls
91 lines (68 loc) · 1.74 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
Adoga Haruna. SRN: 13000236
*/
public class TimeableLight extends Light implements Timeable
{
private Time currentTime;
private Time startTime;
private Time stopTime;
public TimeableLight(String name, String type, int macAddress, int rating, String location, Time currentTime, boolean status )
{
super(name, type, macAddress, rating, location, status);
startTime = null;
stopTime = null;
this.currentTime = currentTime;
}
public void setCurrentTime (Time curr)
{
curr = currentTime;
}
public void setTimes(Time startTime, Time stopTime)
{
this.startTime = startTime;
this.stopTime = stopTime;
}
/**
* A method which allows the times to be unset (probably set to null)
*/
public void unSetTimes()
{
startTime = null;
stopTime = null;
}
/**
* Get the start time of this object
* @return the start time
*/
public Time getStartTime()
{
return this.startTime;
}
/**
*
* @return the stop time
*/
public Time getStopTime()
{
return this.stopTime;
}
public void turnOn()
{
if (startTime.equals(currentTime) && super.getStatus() == false)
{
super.setStatus(true);
}
}
public void turnOff ()
{
if (stopTime.equals(currentTime) && super.getStatus() == true)
{
super.setStatus(false);
}
}
public String toString()
{
return super.toString() + "the start time is : " + startTime + ", stop time is : " + stopTime +
" current time is : " + currentTime;
}
}