From b24b7cd83f649588f6df9639390a1fa9a3a810ce Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Sat, 15 Feb 2020 16:51:34 +0100 Subject: [PATCH] Make command an interface --- src/edu/kit/informatik/command/AddSwitch.java | 2 +- src/edu/kit/informatik/command/AddTrack.java | 2 +- src/edu/kit/informatik/command/AddTrain.java | 2 +- src/edu/kit/informatik/command/Command.java | 8 ++++---- src/edu/kit/informatik/command/CreateCoach.java | 2 +- src/edu/kit/informatik/command/CreateEngine.java | 2 +- src/edu/kit/informatik/command/CreateTrainSet.java | 2 +- src/edu/kit/informatik/command/DeleteRollingStock.java | 2 +- src/edu/kit/informatik/command/DeleteTrack.java | 2 +- src/edu/kit/informatik/command/DeleteTrain.java | 2 +- src/edu/kit/informatik/command/ListCoaches.java | 2 +- src/edu/kit/informatik/command/ListEngines.java | 2 +- src/edu/kit/informatik/command/ListTracks.java | 2 +- src/edu/kit/informatik/command/ListTrainSets.java | 2 +- src/edu/kit/informatik/command/ListTrains.java | 2 +- src/edu/kit/informatik/command/PutTrain.java | 2 +- src/edu/kit/informatik/command/SetSwitch.java | 2 +- src/edu/kit/informatik/command/ShowTrain.java | 2 +- src/edu/kit/informatik/command/Step.java | 2 +- 19 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/edu/kit/informatik/command/AddSwitch.java b/src/edu/kit/informatik/command/AddSwitch.java index dbe5f45..c72ddbd 100644 --- a/src/edu/kit/informatik/command/AddSwitch.java +++ b/src/edu/kit/informatik/command/AddSwitch.java @@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal; * @author Arne Keller * @version 1.0 */ -public class AddSwitch extends Command { +public class AddSwitch implements Command { private final Point start; private final Point end1; private final Point end2; diff --git a/src/edu/kit/informatik/command/AddTrack.java b/src/edu/kit/informatik/command/AddTrack.java index 6cc0928..f4e70a6 100644 --- a/src/edu/kit/informatik/command/AddTrack.java +++ b/src/edu/kit/informatik/command/AddTrack.java @@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal; * @author Arne Keller * @version 1.0 */ -public class AddTrack extends Command { +public class AddTrack implements Command { private Point start; private Point end; diff --git a/src/edu/kit/informatik/command/AddTrain.java b/src/edu/kit/informatik/command/AddTrain.java index 8704d3f..9103b5e 100644 --- a/src/edu/kit/informatik/command/AddTrain.java +++ b/src/edu/kit/informatik/command/AddTrain.java @@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal; * @author Arne Keller * @version 1.0 */ -public class AddTrain extends Command { +public class AddTrain implements Command { private final int trainId; private final String rollingStockId; diff --git a/src/edu/kit/informatik/command/Command.java b/src/edu/kit/informatik/command/Command.java index 231b1c7..9006d11 100644 --- a/src/edu/kit/informatik/command/Command.java +++ b/src/edu/kit/informatik/command/Command.java @@ -3,12 +3,12 @@ package edu.kit.informatik.command; import edu.kit.informatik.ModelRailwaySimulation; /** - * Generic command that can be applied to a simulation. - * Commands are implemented as separate classes to avoid god enums :) + * Command that can be applied to a simulation. + * Commands are implemented as separate classes to avoid a god enum :) * * @author Arne Keller * @version 1.0 */ -public abstract class Command { - public abstract void apply(ModelRailwaySimulation simulation); +public interface Command { + void apply(ModelRailwaySimulation simulation); } diff --git a/src/edu/kit/informatik/command/CreateCoach.java b/src/edu/kit/informatik/command/CreateCoach.java index 888364d..ca4690c 100644 --- a/src/edu/kit/informatik/command/CreateCoach.java +++ b/src/edu/kit/informatik/command/CreateCoach.java @@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal; * @author Arne Keller * @version 1.0 */ -public class CreateCoach extends Command { +public class CreateCoach implements Command { private final CoachType type; private final int length; private final boolean couplingFront; diff --git a/src/edu/kit/informatik/command/CreateEngine.java b/src/edu/kit/informatik/command/CreateEngine.java index 0fa94eb..863e551 100644 --- a/src/edu/kit/informatik/command/CreateEngine.java +++ b/src/edu/kit/informatik/command/CreateEngine.java @@ -8,7 +8,7 @@ import edu.kit.informatik.*; * @author Arne Keller * @version 1.0 */ -public class CreateEngine extends Command { +public class CreateEngine implements Command { private final EngineType type; private final String series; private final String name; diff --git a/src/edu/kit/informatik/command/CreateTrainSet.java b/src/edu/kit/informatik/command/CreateTrainSet.java index eefac54..0dc251c 100644 --- a/src/edu/kit/informatik/command/CreateTrainSet.java +++ b/src/edu/kit/informatik/command/CreateTrainSet.java @@ -10,7 +10,7 @@ import edu.kit.informatik.TrainSet; * @author Arne Keller * @version Arne Keller */ -public class CreateTrainSet extends Command { +public class CreateTrainSet implements Command { private final String series; private final String name; private final int length; diff --git a/src/edu/kit/informatik/command/DeleteRollingStock.java b/src/edu/kit/informatik/command/DeleteRollingStock.java index 98437a7..21cd31a 100644 --- a/src/edu/kit/informatik/command/DeleteRollingStock.java +++ b/src/edu/kit/informatik/command/DeleteRollingStock.java @@ -9,7 +9,7 @@ import edu.kit.informatik.Terminal; * @author Arne Keller * @version 1.0 */ -public class DeleteRollingStock extends Command { +public class DeleteRollingStock implements Command { private final String id; /** diff --git a/src/edu/kit/informatik/command/DeleteTrack.java b/src/edu/kit/informatik/command/DeleteTrack.java index a5b246f..db6c233 100644 --- a/src/edu/kit/informatik/command/DeleteTrack.java +++ b/src/edu/kit/informatik/command/DeleteTrack.java @@ -9,7 +9,7 @@ import edu.kit.informatik.Terminal; * @author Arne Keller * @version 1.0 */ -public class DeleteTrack extends Command { +public class DeleteTrack implements Command { private final int id; /** diff --git a/src/edu/kit/informatik/command/DeleteTrain.java b/src/edu/kit/informatik/command/DeleteTrain.java index e45d3aa..dfb9d7d 100644 --- a/src/edu/kit/informatik/command/DeleteTrain.java +++ b/src/edu/kit/informatik/command/DeleteTrain.java @@ -9,7 +9,7 @@ import edu.kit.informatik.Terminal; * @author Arne Keller * @version 1.0 */ -public class DeleteTrain extends Command { +public class DeleteTrain implements Command { private final int id; /** diff --git a/src/edu/kit/informatik/command/ListCoaches.java b/src/edu/kit/informatik/command/ListCoaches.java index f13d8f9..915f215 100644 --- a/src/edu/kit/informatik/command/ListCoaches.java +++ b/src/edu/kit/informatik/command/ListCoaches.java @@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation; * @author Arne Keller * @version 1.0 */ -public class ListCoaches extends Command { +public class ListCoaches implements Command { @Override public void apply(final ModelRailwaySimulation simulation) { simulation.printCoaches(); diff --git a/src/edu/kit/informatik/command/ListEngines.java b/src/edu/kit/informatik/command/ListEngines.java index 302594b..b6b127f 100644 --- a/src/edu/kit/informatik/command/ListEngines.java +++ b/src/edu/kit/informatik/command/ListEngines.java @@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation; * @author Arne Keller * @version 1.0 */ -public class ListEngines extends Command { +public class ListEngines implements Command { @Override public void apply(final ModelRailwaySimulation simulation) { simulation.printEngines(); diff --git a/src/edu/kit/informatik/command/ListTracks.java b/src/edu/kit/informatik/command/ListTracks.java index 98dbff9..5d00452 100644 --- a/src/edu/kit/informatik/command/ListTracks.java +++ b/src/edu/kit/informatik/command/ListTracks.java @@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation; * @author Arne Keller * @version 1.0 */ -public class ListTracks extends Command { +public class ListTracks implements Command { @Override public void apply(final ModelRailwaySimulation simulation) { simulation.printTracks(); diff --git a/src/edu/kit/informatik/command/ListTrainSets.java b/src/edu/kit/informatik/command/ListTrainSets.java index 9cb6783..6caa4d4 100644 --- a/src/edu/kit/informatik/command/ListTrainSets.java +++ b/src/edu/kit/informatik/command/ListTrainSets.java @@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation; * @author Arne Keller * @version 1.0 */ -public class ListTrainSets extends Command { +public class ListTrainSets implements Command { @Override public void apply(final ModelRailwaySimulation simulation) { simulation.printTrainSets(); diff --git a/src/edu/kit/informatik/command/ListTrains.java b/src/edu/kit/informatik/command/ListTrains.java index 8bd08b5..548bbd3 100644 --- a/src/edu/kit/informatik/command/ListTrains.java +++ b/src/edu/kit/informatik/command/ListTrains.java @@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation; * @author Arne Keller * @version 1.0 */ -public class ListTrains extends Command { +public class ListTrains implements Command { @Override public void apply(final ModelRailwaySimulation simulation) { simulation.printTrains(); diff --git a/src/edu/kit/informatik/command/PutTrain.java b/src/edu/kit/informatik/command/PutTrain.java index f0be681..80eec34 100644 --- a/src/edu/kit/informatik/command/PutTrain.java +++ b/src/edu/kit/informatik/command/PutTrain.java @@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal; * @author Arne Keller * @version 1.0 */ -public class PutTrain extends Command { +public class PutTrain implements Command { private final int id; private final Point point; private final int x; diff --git a/src/edu/kit/informatik/command/SetSwitch.java b/src/edu/kit/informatik/command/SetSwitch.java index 1734724..b6f5c30 100644 --- a/src/edu/kit/informatik/command/SetSwitch.java +++ b/src/edu/kit/informatik/command/SetSwitch.java @@ -10,7 +10,7 @@ import edu.kit.informatik.Terminal; * @author Arne Keller * @version 1.0 */ -public class SetSwitch extends Command { +public class SetSwitch implements Command { private final int id; private final Point point; diff --git a/src/edu/kit/informatik/command/ShowTrain.java b/src/edu/kit/informatik/command/ShowTrain.java index e46b74f..affd267 100644 --- a/src/edu/kit/informatik/command/ShowTrain.java +++ b/src/edu/kit/informatik/command/ShowTrain.java @@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation; * @author Arne Keller * @version 1.0 */ -public class ShowTrain extends Command { +public class ShowTrain implements Command { private final int id; /** diff --git a/src/edu/kit/informatik/command/Step.java b/src/edu/kit/informatik/command/Step.java index b40c438..db9e5cb 100644 --- a/src/edu/kit/informatik/command/Step.java +++ b/src/edu/kit/informatik/command/Step.java @@ -8,7 +8,7 @@ import edu.kit.informatik.ModelRailwaySimulation; * @author Arne Keller * @version 1.0 */ -public class Step extends Command { +public class Step implements Command { private final short speed; /**