-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoom.java
59 lines (49 loc) · 1.22 KB
/
Room.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
public class Room implements RoomInterface{
private String[] roomData;
// [0] = room_id, [1] = (room) name, [2] = host_id, [3] = host_name, [4] = neighborhood, [5] = room_type, [6] = price
Room(String[] rooms)
{
roomData = rooms;
}
@Override
public String getRoomId() {
return this.roomData[0];
}
@Override
public String getName() {
return this.roomData[1];
}
@Override
public String getHostId() {
return this.roomData[2];
}
@Override
public String getHostName() {
return this.roomData[3];
}
@Override
public String getNeighborhoodName() {
return this.roomData[4];
}
@Override
public String getRoomType() {
return this.roomData[5];
}
@Override
public int getPrice() {
this.roomData[6] = this.roomData[6].trim();
return Integer.parseInt(this.roomData[6]);
}
@Override
public int compareTo(RoomInterface otherRoom) {
if(this.getPrice() != otherRoom.getPrice())
return this.getPrice()-otherRoom.getPrice();
return this.getRoomId().compareTo(otherRoom.getRoomId());
}
@Override
public boolean equals(RoomInterface otherRoom) {
if(this.getRoomId().equals(otherRoom.getRoomId()))
return true;
return false;
}
}