mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final1.git
synced 2024-11-24 01:15:05 +00:00
Make sure rolling stock has at least one coupling
This commit is contained in:
parent
8f8baf6701
commit
324231ef07
@ -27,13 +27,16 @@ public abstract class RollingStock {
|
|||||||
* @param length length of this rolling stock
|
* @param length length of this rolling stock
|
||||||
* @param couplingFront whether this rolling stock should have a front coupling
|
* @param couplingFront whether this rolling stock should have a front coupling
|
||||||
* @param couplingBack whether this rolling stock should have a back coupling
|
* @param couplingBack whether this rolling stock should have a back coupling
|
||||||
* @throws InvalidInputException on invalid user input (zero-sized coach)
|
* @throws InvalidInputException on invalid user input (e.g. zero-sized coach)
|
||||||
*/
|
*/
|
||||||
protected RollingStock(final int length, final boolean couplingFront, final boolean couplingBack)
|
protected RollingStock(final int length, final boolean couplingFront, final boolean couplingBack)
|
||||||
throws InvalidInputException {
|
throws InvalidInputException {
|
||||||
if (length < 1) {
|
if (length < 1) {
|
||||||
throw new InvalidInputException("rolling stock length has to be positive");
|
throw new InvalidInputException("rolling stock length has to be positive");
|
||||||
}
|
}
|
||||||
|
if (!couplingFront && !couplingBack) {
|
||||||
|
throw new InvalidInputException("rolling stocks needs at least one coupling");
|
||||||
|
}
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.couplingFront = couplingFront;
|
this.couplingFront = couplingFront;
|
||||||
this.couplingBack = couplingBack;
|
this.couplingBack = couplingBack;
|
||||||
|
Loading…
Reference in New Issue
Block a user