-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicle.java
More file actions
43 lines (36 loc) · 1.06 KB
/
Vehicle.java
File metadata and controls
43 lines (36 loc) · 1.06 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
class Vehicle{
String vehicleType;
int start;
int destination;
String vehicleNumber;
boolean isVIP;
int totalamountpaid = 0;
int journeyamount = 0;
int journeyscount = 0;
ArrayList<String> journeytolls = new ArrayList<>();
int tollpaid[];
HashMap<Integer, Integer> journeys = new HashMap<>();
public Vehicles(String vehicleType, String vehicleNumber, int totalpoints, char isVIP){
this.vehicleType = vehicleType;
this.vehicleNumber = vehicleNumber;
tollpaid = new int[totalpoints];
if(isVIP == 'T')
this.isVIP = true;
else
this.isVIP = false;
}
public void updateJourney(int tollpaid[], int journeyamount, HashMap<Integer, Integer> journeys, int journeyscount){
String res = "";
for(int i = 0; i<tollpaid.length; i++){
if(tollpaid[i] != 0){
res += ("---"+Integer.toString(i));
tollpaid[i] = 0;
}
}
journeytolls.add(res);
this.totalamountpaid+=journeyamount;
this.journeyamount = 0;
this.journeyscount = ++journeyscount;
journeys.put(journeyscount,journeyamount);
}
}ś