-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSafetySystem.java
More file actions
51 lines (38 loc) · 1.58 KB
/
SafetySystem.java
File metadata and controls
51 lines (38 loc) · 1.58 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
public class SafetySystem {
private ParkingLot parkingLot;
public SafetySystem(ParkingLot parkingLot){
this.parkingLot = parkingLot;
}
public void handleFire(){
System.out.println("FIRE DETECTED! Starting safety protocol.");
evacuateVehicles();
alertFireDepartment();
}
public void handleTheft(Vehicle vehicle){
System.out.println("THEFT DETECTED for vehicle " + vehicle.getVehicleNum());
alertSecurity(vehicle);
alertPolice(vehicle);
lockParkingLot();
}
public void evacuateVehicles(){
for (ParkingSpot spot : parkingLot.getSpots()){
if(spot.getOccupancyStatus()){
System.out.println("Please whoever owns " + spot.getSpotID() + " vehicle." + " start evacuating");
spot.setOccupancyStatus(false);
}
}
System.out.println("All vehicles start evacuating");
}
public void alertFireDepartment(){
System.out.println("Fire Department alerted. Help is on the way.");
}
public void alertSecurity(Vehicle vehicle){
System.out.println("Security alerted to monitor theft of vehicle " + vehicle.getVehicleNum());
}
public void alertPolice(Vehicle vehicle){
System.out.println("Police has been called and is on its way for theft of vehicle " + vehicle.getVehicleNum());
}
public void lockParkingLot(){
System.out.println("Parking Lot has been locked due to security concerns. All entry and exit points are locked.");
}
}