forked from jcrouser/CSC120-FinalProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLight.java
More file actions
65 lines (59 loc) · 1.55 KB
/
Copy pathLight.java
File metadata and controls
65 lines (59 loc) · 1.55 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
/**
* The Light class represents a single light in the building.
* Each light has a specific position and is associated with a particular floor.
* Lights can be turned on or off and have properties to track their state and
* location.
*/
class Light {
public boolean isOff;
public final int floor;
public final int position;
/**
* Constructs a Light object with a specified floor and position.
* The light is initialized in the "off" state.
*
* @param floor the floor number where the light is located
* @param position the position of the light on the floor
*/
public Light(int floor, int position) {
this.isOff = true;
this.floor = floor;
this.position = position;
}
/**
* Checks whether the light is currently off.
*
* @return true if the light is off, false otherwise
*/
public boolean isOff() {
return isOff;
}
/**
* Turns off the light, changing its state to "off."
*/
public void turnOn() {
this.isOff = false;
}
/**
* Turns on the light, changing its state to "on."
*/
public void turnOff() {
this.isOff = true;
}
/**
* Retrieves the floor number where the light is located.
*
* @return the floor number
*/
public int getFloor() {
return floor;
}
/**
* Retrieves the position of the light on its floor.
*
* @return the position of the light on the floor
*/
public int getPosition() {
return position;
}
}