-
Notifications
You must be signed in to change notification settings - Fork 0
/
Seat.java
109 lines (93 loc) · 2.28 KB
/
Seat.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
public class Seat {
private Passenger passenger;
private double cost;
private SeatClass seatClass;
private int seatRow;
private String seatLetter;
private boolean seatTaken;
private String seatCode;
/**
* Constructor for Seat
* @param passenger
* @param cost
* @param seatClass
* @param seatRow
* @param seatLettrer
* @param seatTaken
*/
public Seat(Passenger passenger, double cost, SeatClass seatClass, int seatRow, String seatLettrer,
boolean seatTaken) {
this.passenger = passenger;
this.cost = cost;
this.seatClass = seatClass;
this.seatRow = seatRow;
this.seatLetter = seatLettrer;
this.seatTaken = seatTaken;
seatCode = seatRow + seatLetter;
}
/**
* Getters and setters
* @return
*/
public Passenger getPassenger()
{
return passenger;
}
public void setPassenger(Passenger passenger)
{
this.passenger = passenger;
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
this.cost = cost;
}
public SeatClass getSeatClass()
{
return seatClass;
}
public void setSeatClass(SeatClass seatClass)
{
this.seatClass = seatClass;
}
public int getseatRow()
{
return seatRow;
}
public void setseatRow(int seatRow)
{
this.seatRow = seatRow;
}
public String getSeatLetter()
{
return seatLetter;
}
public void setSeatLetter(String seatLetter)
{
this.seatLetter = seatLetter;
}
public boolean isSeatTaken()
{
return seatTaken;
}
public void setSeatTaken(boolean seatTaken)
{
this.seatTaken = seatTaken;
}
public String getSeatCode() {
return seatCode;
}
/**
* Converts the seat information to a String
*/
public String toString() {
String ret = seatClass.getName() + " seat " + seatCode + " costing $" + cost;
if (isSeatTaken()) {
ret += " occupied.";
} else {
ret += "unoccupied.";
}
return ret;
}
}