-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocation.java
60 lines (48 loc) · 1.62 KB
/
Location.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
public class Location{
private String roomName;
private double latitude;
private double longitude;
private String buildingName;
private String address;
private String postcode;
private int freeSeats;
private final int totalSeats;
public Location(String roomName, double latitude, double longitude, String buildingName, String address, String postcode, int freeSeats, int totalSeats){
this.roomName = roomName;
this.latitude = latitude;
this.longitude = longitude;
this.buildingName = buildingName;
this.address = address;
this.postcode = postcode;
this.freeSeats = freeSeats;
this.totalSeats = totalSeats;
}
public String toString(){
String locationString = this.roomName + ": (" + this.latitude + ", "+ this.longitude + "). " + this.buildingName + ", " + this.address + ", " + this.postcode + ". "+ this.freeSeats + " from " + this.totalSeats + " seats are free.";
return locationString;
}
public int getFreeSeats(){
return this.freeSeats;
}
public double getFreeSeatsPercentage(){
return this.totalSeats != 0 ? ((double) this.freeSeats)/this.totalSeats : 0;
}
public int getTotalSeats(){
return this.totalSeats;
}
public double getLatitude(){
return this.latitude;
}
public double getLongitude(){
return this.longitude;
}
public String getPostcode(){
return this.postcode;
}
public String getBuilding(){
return this.buildingName;
}
public String getRoomName(){
return this.roomName;
}
}