Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Source code recreated from a .class file by IntelliJ IDEA
- // (powered by Fernflower decompiler)
- //
- package softUniParking;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- public class Parking {
- private Map<String, Car> cars = new HashMap();
- private int capacity;
- public Parking(int capacity) {
- this.capacity = capacity;
- }
- public String addCar(Car car) {
- if (this.cars.containsKey(car.getRegistrationNumber())) {
- return "Car with that registration number, already exists!";
- } else if (this.cars.size() >= this.capacity) {
- return "Parking is full!";
- } else {
- this.cars.putIfAbsent(car.getRegistrationNumber(), car);
- String var10000 = car.getMake();
- return "Successfully added new car " + var10000 + " " + car.getRegistrationNumber();
- }
- }
- public String removeCar(String registrationNumber) {
- if (!this.cars.containsKey(registrationNumber)) {
- return "Car with that registration number, doesn't exists!";
- } else {
- this.cars.remove(registrationNumber);
- return "Successfully removed " + registrationNumber;
- }
- }
- public Car getCar(String registrationNumber) {
- return (Car)this.cars.get(registrationNumber);
- }
- public void removeSetOfRegistrationNumber(List<String> registrationNumbers) {
- Iterator var2 = registrationNumbers.iterator();
- while(var2.hasNext()) {
- String registrationNumber = (String)var2.next();
- this.removeCar(registrationNumber);
- }
- }
- public int getCount() {
- return this.cars.size();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement