-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathParking.java
More file actions
47 lines (38 loc) · 1.13 KB
/
Copy pathParking.java
File metadata and controls
47 lines (38 loc) · 1.13 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
/**
* Created by Paca on 3/21/14.
*/
public class Parking {
private int cashier;
private Pila parkPlace;
private Pila auxParkPlace;
public Parking() {
cashier = 0;
parkPlace = new PilaE();
auxParkPlace = new PilaE();
}
public void addCar(Auto carToAdd){
parkPlace.apilar(carToAdd);
cashier = cashier + 5;
}
public void removeCar(String patentOfCarToRemove){
if (parkPlace.verTope() != null){
Auto carToAnalize = (Auto) parkPlace.verTope();
try {
while (!carToAnalize.getPatente().equals(patentOfCarToRemove)){
auxParkPlace.apilar(parkPlace.verTope());
parkPlace.desapilar();
carToAnalize = (Auto) parkPlace.verTope();
}
} catch (NullPointerException e){
}
}
parkPlace.desapilar();
while (auxParkPlace.verTope() != null){
parkPlace.apilar(auxParkPlace.verTope());
auxParkPlace.desapilar();
}
}
public Parking(int cashier) {
this.cashier = cashier;
}
}