Make command an interface

This commit is contained in:
Arne Keller 2020-02-15 16:51:34 +01:00
parent 972000204f
commit b24b7cd83f
19 changed files with 22 additions and 22 deletions

View File

@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class AddSwitch extends Command { public class AddSwitch implements Command {
private final Point start; private final Point start;
private final Point end1; private final Point end1;
private final Point end2; private final Point end2;

View File

@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class AddTrack extends Command { public class AddTrack implements Command {
private Point start; private Point start;
private Point end; private Point end;

View File

@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class AddTrain extends Command { public class AddTrain implements Command {
private final int trainId; private final int trainId;
private final String rollingStockId; private final String rollingStockId;

View File

@ -3,12 +3,12 @@ package edu.kit.informatik.command;
import edu.kit.informatik.ModelRailwaySimulation; import edu.kit.informatik.ModelRailwaySimulation;
/** /**
* Generic command that can be applied to a simulation. * Command that can be applied to a simulation.
* Commands are implemented as separate classes to avoid god enums :) * Commands are implemented as separate classes to avoid a god enum :)
* *
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public abstract class Command { public interface Command {
public abstract void apply(ModelRailwaySimulation simulation); void apply(ModelRailwaySimulation simulation);
} }

View File

@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class CreateCoach extends Command { public class CreateCoach implements Command {
private final CoachType type; private final CoachType type;
private final int length; private final int length;
private final boolean couplingFront; private final boolean couplingFront;

View File

@ -8,7 +8,7 @@ import edu.kit.informatik.*;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class CreateEngine extends Command { public class CreateEngine implements Command {
private final EngineType type; private final EngineType type;
private final String series; private final String series;
private final String name; private final String name;

View File

@ -10,7 +10,7 @@ import edu.kit.informatik.TrainSet;
* @author Arne Keller * @author Arne Keller
* @version Arne Keller * @version Arne Keller
*/ */
public class CreateTrainSet extends Command { public class CreateTrainSet implements Command {
private final String series; private final String series;
private final String name; private final String name;
private final int length; private final int length;

View File

@ -9,7 +9,7 @@ import edu.kit.informatik.Terminal;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class DeleteRollingStock extends Command { public class DeleteRollingStock implements Command {
private final String id; private final String id;
/** /**

View File

@ -9,7 +9,7 @@ import edu.kit.informatik.Terminal;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class DeleteTrack extends Command { public class DeleteTrack implements Command {
private final int id; private final int id;
/** /**

View File

@ -9,7 +9,7 @@ import edu.kit.informatik.Terminal;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class DeleteTrain extends Command { public class DeleteTrain implements Command {
private final int id; private final int id;
/** /**

View File

@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class ListCoaches extends Command { public class ListCoaches implements Command {
@Override @Override
public void apply(final ModelRailwaySimulation simulation) { public void apply(final ModelRailwaySimulation simulation) {
simulation.printCoaches(); simulation.printCoaches();

View File

@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class ListEngines extends Command { public class ListEngines implements Command {
@Override @Override
public void apply(final ModelRailwaySimulation simulation) { public void apply(final ModelRailwaySimulation simulation) {
simulation.printEngines(); simulation.printEngines();

View File

@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class ListTracks extends Command { public class ListTracks implements Command {
@Override @Override
public void apply(final ModelRailwaySimulation simulation) { public void apply(final ModelRailwaySimulation simulation) {
simulation.printTracks(); simulation.printTracks();

View File

@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class ListTrainSets extends Command { public class ListTrainSets implements Command {
@Override @Override
public void apply(final ModelRailwaySimulation simulation) { public void apply(final ModelRailwaySimulation simulation) {
simulation.printTrainSets(); simulation.printTrainSets();

View File

@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class ListTrains extends Command { public class ListTrains implements Command {
@Override @Override
public void apply(final ModelRailwaySimulation simulation) { public void apply(final ModelRailwaySimulation simulation) {
simulation.printTrains(); simulation.printTrains();

View File

@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class PutTrain extends Command { public class PutTrain implements Command {
private final int id; private final int id;
private final Point point; private final Point point;
private final int x; private final int x;

View File

@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class SetSwitch extends Command { public class SetSwitch implements Command {
private final int id; private final int id;
private final Point point; private final Point point;

View File

@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class ShowTrain extends Command { public class ShowTrain implements Command {
private final int id; private final int id;
/** /**

View File

@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation;
* @author Arne Keller * @author Arne Keller
* @version 1.0 * @version 1.0
*/ */
public class Step extends Command { public class Step implements Command {
private final short speed; private final short speed;
/** /**