-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPassenger.java
34 lines (28 loc) · 1.09 KB
/
Passenger.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
import java.util.List;
public class Passenger extends User {
// Additional attribute
private List<String> paymentMethods;
// Constructor
public Passenger(String userId, String name, Location location, List<String> paymentMethods) {
super(userId, name, location); // Call the constructor of the abstract User class
this.paymentMethods = paymentMethods;
}
// Method to request a ride
public RideRequest requestRide(Location destination) {
return new RideRequest(this.userId, this.location, destination); // Creates and returns a new ride request
}
// Method to rate a driver
public void rateDriver(String driverId, float rating) {
// Logic to rate the driver
System.out.println("Passenger " + this.name + " rated Driver " + driverId + " with a rating of " + rating);
}
// Implementation of the abstract method from User class
@Override
public String getRole() {
return "Passenger";
}
// Getter for payment methods
public List<String> getPaymentMethods() {
return paymentMethods;
}
}