-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathPassenger.java
More file actions
32 lines (24 loc) · 761 Bytes
/
Passenger.java
File metadata and controls
32 lines (24 loc) · 761 Bytes
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
public class Passenger {
public String name; //changed to public
public Passenger(String name){
this.name = name;
}
// doesn't allow passenger to board car if its full
public void boardCar(Car c){
if (c.addPassenger(this) == false ) {
System.out.println("Sorry, this car is full.");
}
}
// removes passenger from car if its full, tells them to go to another
public void getOffCar(Car c){
if (c.removePassenger(this) == false ) {
System.out.println("Sorry, try the next car.");
}
}
// assigns names to passenger
public static void main(String[] args) {
Passenger person = new Passenger ("Julie");
Passenger person1 = new Passenger ("Jo");
Passenger person2 = new Passenger("Olohi");
}
}