-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassenger.java
More file actions
50 lines (47 loc) · 2.19 KB
/
Passenger.java
File metadata and controls
50 lines (47 loc) · 2.19 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
//Sina Pahlavan
//501 034 271
public class Passenger {
private String name;//This string represents a person's name
private String passportNum;//an integer to represent a person's passport number
private String seatNum;
private String seatType;
public Passenger(String name,String passnum,String seatnum){//This constructor class is only called if the seat number is stated
this.name = name;
this.passportNum = passnum;
this.seatNum = seatnum;//The seat number is randomly generated by class Flight. It will be based on the aircraft's capacity.
}
public Passenger(String name,String passnum){//This constructor is called if the seat num is called when the seat num is not included
this.name = name;
this.passportNum = passnum;
this.seatNum=" ";//initially the seat number will be equal to zero. Then, class flight will add the passenger to
//its passengers list(after checking that they are not already on the flight) and then give it a seat num
}
public String getName(){return this.name;}
public String getPassportNum(){return this.passportNum ;}
public String getSeatNum(){return this.seatNum;}
public boolean equals(Passenger other){//Overriding the equals method
/**
* @ param Passenger other
* @ return boolean
* The function will only return true if a passenger's name and passport number are equal to another person's
*/
if (this.passportNum.equals(other.passportNum) && this.name.equals(other.name)){
return true;
}
return false;//If two people don't have the same name and passport number this will return false
}
public String toString() {
/**
* @ param: none
* return: String
* the return will give a string version of a passenger, stating their name, passport number, and seat number
*/
return "Name: " + this.name + " Passport Number: " + this.passportNum + " Seat Number: " + this.seatNum;
}
public void setSeatNum(String seatNumber){
/**
* used to give a passenger a seat NUm
*/
this.seatNum = seatNumber;
}
}