/**
   * @author Robert Dempsey, Student Number: N5400872 Tests that when passengers board, the
   *     individual cars are filling up, not just a total number on the whole train
   */
  @Test
  public void testIndividualPassengerCarsAreBeingAddedTo() throws TrainException {
    final Integer SEATS = 20;
    final Integer PASSENGERS = 79;
    final Integer GROSS_WEIGHT = 90;
    final Integer ZERO_PASSENGERS = 0;
    final String CLASSIFICATION = "4S";

    final Locomotive LOCOMOTIVE = new Locomotive(GROSS_WEIGHT, CLASSIFICATION);
    final PassengerCar PASSENGER_01 = new PassengerCar(GROSS_WEIGHT, SEATS);
    final PassengerCar PASSENGER_02 = new PassengerCar(GROSS_WEIGHT, SEATS);
    final PassengerCar PASSENGER_03 = new PassengerCar(GROSS_WEIGHT, SEATS);
    final PassengerCar PASSENGER_04 = new PassengerCar(GROSS_WEIGHT, SEATS);

    DepartingTrain departingTrain = new DepartingTrain();
    departingTrain.addCarriage(LOCOMOTIVE);
    departingTrain.addCarriage(PASSENGER_01);
    departingTrain.addCarriage(PASSENGER_02);
    departingTrain.addCarriage(PASSENGER_03);
    departingTrain.addCarriage(PASSENGER_04);

    departingTrain.board(PASSENGERS);

    assertTrue(PASSENGER_01.numberOnBoard() > ZERO_PASSENGERS);
    assertTrue(PASSENGER_02.numberOnBoard() > ZERO_PASSENGERS);
    assertTrue(PASSENGER_03.numberOnBoard() > ZERO_PASSENGERS);
    assertTrue(PASSENGER_04.numberOnBoard() > ZERO_PASSENGERS);
  }
Exemple #2
0
  @Override
  public boolean equals(Object o) {

    // TODO: ask if all these checks before super.equals() are needed
    if (!super.equals(o)) {
      return false;
    }
    PassengerCar other = (PassengerCar) o;
    if (bodyType != other.bodyType) {
      return false;
    }
    if (passengerCapacity != other.getPassengerCapacity()) {
      return false;
    }
    if (baggageSpace != other.getBaggageSpace()) {
      return false;
    }
    return true;
  }