Esempio n. 1
0
  @Test
  public void
      should_park_in_the_most_avaiable_port_parking_lot_when_there_is_only_one_parking_lot() {
    parkingLotList = new ArrayList<ParkingLot>();
    ParkingLot mostAvailableSpaceParkingLot = new ParkingLot(3);
    parkingLotList.add(mostAvailableSpaceParkingLot);
    smartManager = new Manager(parkingLotList, StategyEnum.SMART);

    Car car = new Car();
    Receipt receipt = smartManager.park(car);
    Car car1 = mostAvailableSpaceParkingLot.getCar(receipt);
    assertSame(car, car1);
  }
Esempio n. 2
0
  @Test
  public void
      should_park_the_car_in_the_most_available_port_parking_lot_when_there_are_two_parking_lot()
          throws Exception {
    parkingLotList = new ArrayList<ParkingLot>();
    parkingLotList.add(new ParkingLot(10));
    ParkingLot mostAvailableSpaceParkingLot = new ParkingLot(20);
    parkingLotList.add(mostAvailableSpaceParkingLot);
    smartManager = new Manager(parkingLotList, StategyEnum.SMART);

    Car car = new Car();
    Receipt receipt = smartManager.park(car);
    Car car1 = mostAvailableSpaceParkingLot.getCar(receipt);
    assertSame(car, car1);
  }
  public static void main(String[] args) {
    ParkingLot parkingLot = new ParkingLot();

    Car car1 = new Car("Honda", "Civic", "gray", 2010);
    parkingLot.addCar(car1);
    Car car2 = new Car("Toyota", "Camry", "green", 2011);
    parkingLot.addCar(car2);
    Car car3 = new Car("Ford", "Focus", "silver", 2001);
    parkingLot.addCar(car3);

    ArrayList<Car> myCars = parkingLot.getAllCars();
    for (Car car : myCars) {
      System.out.println(
          "There is a " + car.getColor() + " " + car.getModel() + " in the parking lot.");
    }

    /*
     If done correctly, the output should be the following:
    		There is a gray Civic in the parking lot.
    	There is a green Camry in the parking lot.
    	There is a silver Focus in the parking lot.
    */
  }