-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBus.java
58 lines (45 loc) · 1.42 KB
/
Bus.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
//DO_NOT_EDIT_ANYTHING_ABOVE_THIS_LINE
package vehicles;
import passengers.*;
import interfaces.usePublicTransport;
import main.*;
import interfaces.*;
/**
* This class implements a simple bus which is public transportation vehicle
* with range. Bus has all features of PublicTransport.
*
* @author Hasan Baki Kucukcakiroglu
* @since 2020-03-28
*/
public class Bus extends PublicTransport {
/**
* This construct a bus with an ID and range given as x1,x2,y1,y2 coordinates.
*
* @param ID the ID of vehicle
* @param x1 the range of vehicle on the x axis.
* @param y1 the range of vehicle on the y axis.
* @param x2 the range of vehicle on the x axis.
* @param y2 the range of vehicle on the y axis.
*/
public Bus(int ID, double x1, double y1, double x2, double y2) {
super(ID, x1, y1, x2, y2);
}
/**
* This method calculates the travel fee according to type of passenger and
* distance of travel.
*
* @param p the passenger who wants to travel with this bus.
* @param distance the distance between the current location of the passenger
* and arrival point.
* @return the fee that will be taken from passenger's travel card.If passenger
* is discounted, s/he has %50 discount.
*/
public double getPrice(Passenger p, double distance) {
if (p instanceof DiscountedPassenger) {
return 1.;
} else {
return 2.;
}
}
}
//DO_NOT_EDIT_ANYTHING_BELOW_THIS_LINE