2020-02-16 14:01:33 +00:00
|
|
|
package edu.kit.informatik.model;
|
2020-02-15 14:17:23 +00:00
|
|
|
|
2020-02-18 14:57:04 +00:00
|
|
|
import edu.kit.informatik.ui.InvalidInputException;
|
|
|
|
|
2020-02-16 13:57:54 +00:00
|
|
|
/**
|
|
|
|
* Generic engine, is usually either diesel, steam or electric.
|
|
|
|
*
|
|
|
|
* @author Arne Keller
|
|
|
|
* @version 1.0
|
|
|
|
*/
|
2020-02-15 14:17:23 +00:00
|
|
|
public abstract class Engine extends RollingStock {
|
2020-02-15 15:38:54 +00:00
|
|
|
/**
|
|
|
|
* Series/class of this engine.
|
|
|
|
*/
|
2020-02-18 14:57:04 +00:00
|
|
|
private final String series;
|
2020-02-15 15:38:54 +00:00
|
|
|
/**
|
|
|
|
* Name of this engine.
|
|
|
|
*/
|
2020-02-18 14:57:04 +00:00
|
|
|
private final String name;
|
2020-02-17 10:19:56 +00:00
|
|
|
|
2020-02-18 14:57:04 +00:00
|
|
|
/**
|
|
|
|
* Initialize an engine.
|
|
|
|
* @param series series/class of this engine
|
|
|
|
* @param name name of this engine
|
|
|
|
* @param length length of this engine
|
|
|
|
* @param couplingFront whether this engine should have a front coupling
|
|
|
|
* @param couplingBack whether this engine should have a back coupling
|
|
|
|
* @throws InvalidInputException on invalid user input (zero-sized coach)
|
|
|
|
*/
|
2020-02-17 10:19:56 +00:00
|
|
|
protected Engine(final String series, final String name, final int length,
|
2020-02-18 14:57:04 +00:00
|
|
|
final boolean couplingFront, final boolean couplingBack) throws InvalidInputException {
|
2020-02-17 10:19:56 +00:00
|
|
|
super(length, couplingFront, couplingBack);
|
|
|
|
this.series = series;
|
|
|
|
this.name = name;
|
|
|
|
}
|
2020-02-15 14:17:23 +00:00
|
|
|
|
2020-02-16 13:57:54 +00:00
|
|
|
/**
|
|
|
|
* @return the name of this engine
|
|
|
|
*/
|
2020-02-15 14:17:23 +00:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2020-02-17 10:19:56 +00:00
|
|
|
/**
|
|
|
|
* @return the series of this engine
|
|
|
|
*/
|
|
|
|
public String getSeries() {
|
|
|
|
return series;
|
|
|
|
}
|
|
|
|
|
2020-02-15 14:17:23 +00:00
|
|
|
@Override
|
|
|
|
public String getIdentifier() {
|
|
|
|
return String.format("%s-%s", series, getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-02-18 13:19:45 +00:00
|
|
|
public boolean canCoupleTo(RollingStock rollingStock) {
|
|
|
|
return true;
|
2020-02-15 14:17:23 +00:00
|
|
|
}
|
|
|
|
}
|