-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExit.java
More file actions
58 lines (45 loc) · 1.75 KB
/
Exit.java
File metadata and controls
58 lines (45 loc) · 1.75 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
50
51
52
53
54
55
56
57
58
package garageSystem;
import java.util.ArrayList;
public class Exit {
public void markSlotEmpty(Slot s){
s.markEmpty();
}
public void parkOut(Garage garage ){
int index=-1;
Screen screen = new Screen();
String vehicleID = screen.getVehicleID();
System.out.println("currently =" + garage.slotArray[0].parkedVehicle.getVehicleId()+".");
System.out.println("vehicle id =" + vehicleID +".");
System.out.println("vehicle count = " + garage.getVehicleCount());
for (int i=0 ; i<garage.slotArray.length; i+=1){
System.out.println("inside for loop");
if (garage.slotArray[i].isFull()){
System.out.println("inside first if");
if (garage.slotArray[i].parkedVehicle.getVehicleId().equals(vehicleID)){
System.out.println("vehicle id = " + vehicleID);
System.out.println("currently = " + garage.slotArray[i].parkedVehicle.getVehicleId());
index = i;
}
}
}
while (index == -1){
System.out.println("index == -1");
vehicleID = screen.getVehicleID();
for (int i=0 ; i<garage.slotArray.length; i+=1){
if (garage.slotArray[i].parkedVehicle.getVehicleId()==vehicleID){
index = i;
}
}
}
Time t = new Time();
t.setEndTime(garage.slotArray[index].parkedVehicle);
Payment paymentObj = new Payment();
int fees = paymentObj.calculateFees(garage.slotArray[index].parkedVehicle);
paymentObj.addtoFees(fees, garage);
markSlotEmpty(garage.slotArray[index]);
garage.slotArray[index].markEmpty();
garage.decrementVehiclesCount();
//Screen screen = new Screen();
screen.displayFees(fees);
}
}