public Integer board(Integer newPassengers) throws TrainException {

		if (newPassengers < NO_PASSENGERS) {
			throw new TrainException(
					"The number of new train passengers must by positive");
		}

		if (trainSeatsAbility == NO_SEATS) {
			throw new TrainException("There are no seats on the train.");
		}

		// If there will be leftover passengers after boarding all passenger
		// cars
		if ((newPassengers + passengersOnTrain) > trainSeatsAbility) {
			int unableBoarding = (newPassengers + passengersOnTrain)
					- trainSeatsAbility;
			passengersOnTrain = trainSeatsAbility;

			// Goes through each carriage on the train
			for (int index = 0; index < train.size(); index++) {
				RollingStock temporaryRollingStock = train.get(index);
				// If it is a a passenger car
				if (temporaryRollingStock instanceof PassengerCar) {
					// Board the car with number of available seats
					((PassengerCar) temporaryRollingStock)
							.board(((PassengerCar) temporaryRollingStock)
									.numberOfSeats()
									- ((PassengerCar) temporaryRollingStock)
											.numberOnBoard());
				}
			}
			return unableBoarding;

			// Else there won't be leftover passengers on the whole train
		} else {
			passengersOnTrain += newPassengers;

			// boolean done indicates if we have finished checking if a
			// particular passenger car will fill up
			boolean done = false;
			// Goes through each carriage on the train
			for (int index = 0; index < train.size() && !done; index++) {
				RollingStock temporaryRollingStock = train.get(index);

				// If it is a passenger car
				if (temporaryRollingStock instanceof PassengerCar) {
					// And if there will be leftover passengers from boarding it
					if ((newPassengers + ((PassengerCar) temporaryRollingStock)
							.numberOnBoard()) > ((PassengerCar) temporaryRollingStock)
							.numberOfSeats()) {
						// Set local variable getseat to the number of available
						// seats
						int getseat = (((PassengerCar) temporaryRollingStock)
								.numberOfSeats() - ((PassengerCar) temporaryRollingStock)
								.numberOnBoard());
						// And board the passenger car with the number of
						// available seats
						((PassengerCar) temporaryRollingStock).board(getseat);
						// The number of new passengers has now been reduced by
						// that number of available seats on the passenger car
						newPassengers -= getseat;

						// Else there won't be leftover passengers after
						// boarding this car
					} else {
						// Finished checking if a certain passenger car will
						// fill up
						done = true;
						// Board the rest of the new passengers
						((PassengerCar) temporaryRollingStock)
								.board(newPassengers);
					}
				}
			}
			return NO_PASSENGERS; // There will be no passengers leftover from
									// boarding
		}
	}