forked from counterman1128/Undergraduate_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Floor.java
71 lines (60 loc) · 1.47 KB
/
Floor.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
66
67
68
69
70
71
package Undergraduate_Project;
import Undergraduate_Project.Display;
import Undergraduate_Project.FloorPanel;
import Undergraduate_Project.Door;
public class Floor {
private int floorNumber;
private Display floorDisplay;
private FloorPanel floorPanel;
private Door floorDoor;
public double floorPosition;
public Object panel;
// Default Constructor, by default the floor is 1
public Floor(){
floorNumber = 1;
floorDisplay = new Display();
floorPanel = new FloorPanel();
floorDoor = new Door();
}
// Sets the floor number to n
public Floor(int n) {
floorPosition = n * 10 - 10;
floorNumber = n;
floorDisplay = new Display();
floorPanel = new FloorPanel();
floorDoor = new Door();
panel = floorPanel.getPanelState();
}
// Accessors
public int getFloorNumber() {
return floorNumber;
}
public Display getFloorDisplay() {
return floorDisplay;
}
public FloorPanel getFloorPanel() {
return floorPanel;
}
public Door getFloorDoor() {
return floorDoor;
}
public int getFloorPanelState(){
if(floorPanel.getUpButtonPressed())
return 1;
else if(floorPanel.getDownButtonPressed())
return -1;
return 0;
}
public Object returnPanelStatus(){
return panel;
}
public void closeFloorDoor()throws InterruptedException{
floorDoor.setDoorOpen(false);
}
public void openFloorDoor()throws InterruptedException{
floorDoor.setDoorOpen(true);
}
public boolean floorDoorStatus(){
return floorDoor.getDoorOpen();
}
}