-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParkingSpot.java
More file actions
43 lines (38 loc) · 1.53 KB
/
Copy pathParkingSpot.java
File metadata and controls
43 lines (38 loc) · 1.53 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
package com.parking.model;
public class ParkingSpot {
private String id;
private String zone; // A, B, C
private int level; // Floor number
private int spotNumber;
private SpotType type;
private SpotStatus status;
private String vehicleId;
private long occupiedSince;
public enum SpotType {
REGULAR, COMPACT, HANDICAPPED, EV_CHARGING, PREMIUM
}
public enum SpotStatus {
AVAILABLE, OCCUPIED, RESERVED, MAINTENANCE
}
public ParkingSpot(String zone, int level, int spotNumber, SpotType type) {
this.id = zone + level + String.format("%02d", spotNumber);
this.zone = zone;
this.level = level;
this.spotNumber = spotNumber;
this.type = type;
this.status = SpotStatus.AVAILABLE;
}
// Getters and Setters
public String getId() { return id; }
public String getZone() { return zone; }
public int getLevel() { return level; }
public int getSpotNumber() { return spotNumber; }
public SpotType getType() { return type; }
public SpotStatus getStatus() { return status; }
public void setStatus(SpotStatus status) { this.status = status; }
public String getVehicleId() { return vehicleId; }
public void setVehicleId(String vehicleId) { this.vehicleId = vehicleId; }
public long getOccupiedSince() { return occupiedSince; }
public void setOccupiedSince(long occupiedSince) { this.occupiedSince = occupiedSince; }
public boolean isAvailable() { return status == SpotStatus.AVAILABLE; }
}