-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRide.java
More file actions
49 lines (48 loc) · 1.35 KB
/
Ride.java
File metadata and controls
49 lines (48 loc) · 1.35 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
package com.RapidoApp;
public class Ride {
protected String customerName;
protected String rideId;
protected double distanceKm;
public static final String appName="App Name:Rapido";
Ride(String customerName,String rideId,double distanceKm){
setCustomerName(customerName);
setRideId(rideId);
setDistanceKm(distanceKm);
}
public void setCustomerName(String customerName) {
if(!customerName.isEmpty()) {
this.customerName=customerName;
}
else {
System.out.println("Customer name cannot be empty!");
System.exit(0);
}
}
public void setRideId(String rideId) {
if(!rideId.isEmpty()) {
this.rideId=rideId;
}
else {
System.out.println("Ride ID cannot be empty!");
System.exit(0);
}
}
public void setDistanceKm(double distanceKm) {
if((distanceKm<0)) {
System.out.println("Distance cannot be negative!");
System.exit(0);
}
else {
this.distanceKm=distanceKm;
}
}
public void calculateFare() {
System.out.println("Calculating Fare!");
}
public String displayRideDetails() {
return "Customer Name: "+customerName+
"\nRide ID: "+rideId+
"\nDistance (in km): "+distanceKm+
"\n"+appName;
}
}