Ejemplo n.º 1
0
  /**
   * Test Boarding Passengers to a Valid Train
   *
   * @throws TrainException
   */
  @Test
  public void testBoardPassengersValidTrainPositive() throws TrainException {
    final Integer PASSENGERS = 20;
    final Integer GROSS_WEIGHT = 90;
    final String POWER_CLASS = "4S";

    final Locomotive LOCO = new Locomotive(GROSS_WEIGHT, POWER_CLASS);
    final PassengerCar PASSENGER = new PassengerCar(GROSS_WEIGHT, PASSENGERS);

    DepartingTrain departingTrain = new DepartingTrain();
    departingTrain.addCarriage(LOCO);
    departingTrain.addCarriage(PASSENGER);
    @SuppressWarnings("unused")
    Integer noSeats = departingTrain.board(PASSENGERS);
    assertEquals(departingTrain.numberOnBoard(), PASSENGERS);
  }
Ejemplo n.º 2
0
  /**
   * Test Boarding Passengers to a Valid Combo Train with multiple PassengerCar carriages and single
   * FreightCar carriages
   *
   * @throws TrainException
   */
  @Test
  public void testBoardPassengersValidComboTrainPassengerMultiple() throws TrainException {
    final Integer SEATS = 20;
    final Integer PASSENGERS = SEATS * 2;
    final Integer GROSS_WEIGHT = 90;
    final String POWER_CLASS = "4S";
    final String GOODS_TYPE = "G";

    final Locomotive LOCO = new Locomotive(GROSS_WEIGHT, POWER_CLASS);
    final FreightCar FREIGHT = new FreightCar(GROSS_WEIGHT, GOODS_TYPE);
    final PassengerCar PASSENGER01 = new PassengerCar(GROSS_WEIGHT, SEATS);
    final PassengerCar PASSENGER02 = new PassengerCar(GROSS_WEIGHT, SEATS);

    DepartingTrain departingTrain = new DepartingTrain();
    departingTrain.addCarriage(LOCO);
    departingTrain.addCarriage(PASSENGER01);
    departingTrain.addCarriage(PASSENGER02);
    departingTrain.addCarriage(FREIGHT);
    @SuppressWarnings("unused")
    Integer noSeats = departingTrain.board(PASSENGERS);
    assertEquals(departingTrain.numberOnBoard(), PASSENGERS);
  }