Add javadoc

This commit is contained in:
Arne Keller 2020-02-15 15:44:07 +01:00
parent 1e8026216a
commit ac089109b2
6 changed files with 73 additions and 0 deletions

View File

@ -4,11 +4,23 @@ import edu.kit.informatik.ModelRailwaySimulation;
import edu.kit.informatik.Point;
import edu.kit.informatik.Terminal;
/**
* Command used to add a switch to the rail network.
*
* @author Arne Keller
* @version 1.0
*/
public class AddSwitch extends Command {
private final Point start;
private final Point end1;
private final Point end2;
/**
* Construct a new 'add switch' command.
* @param start start position
* @param end1 end position 1
* @param end2 end position 2
*/
public AddSwitch(final Point start, final Point end1, final Point end2) {
this.start = start;
this.end1 = end1;

View File

@ -4,10 +4,21 @@ import edu.kit.informatik.ModelRailwaySimulation;
import edu.kit.informatik.Point;
import edu.kit.informatik.Terminal;
/**
* Command used to add a track to the rail network.
*
* @author Arne Keller
* @version 1.0
*/
public class AddTrack extends Command {
private Point start;
private Point end;
/**
* Construct a new 'add track' command.
* @param start
* @param end
*/
public AddTrack(final Point start, final Point end) {
this.start = start;
this.end = end;

View File

@ -4,10 +4,21 @@ import edu.kit.informatik.ModelRailwaySimulation;
import edu.kit.informatik.RollingStock;
import edu.kit.informatik.Terminal;
/**
* Command used to construct a new train or modify an existing train.
*
* @author Arne Keller
* @version 1.0
*/
public class AddTrain extends Command {
private final int trainId;
private final String rollingStockId;
/**
* Construct a new 'add train' command.
* @param trainId identifier of the train to be added/modified
* @param rollingStockId identifer of the rolling to be added to the train
*/
public AddTrain(final int trainId, final String rollingStockId) {
this.trainId = trainId;
this.rollingStockId = rollingStockId;

View File

@ -7,6 +7,12 @@ import edu.kit.informatik.Terminal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Factory used to parse user input into commands.
*
* @author Arne Keller
* @version 1.0
*/
public class CommandFactory {
public static final String ADD_TRACK = "add track";
public static final Pattern ADD_TRACK_ARGUMENTS
@ -46,6 +52,11 @@ public class CommandFactory {
public static final String STEP = "step";
public static final String POSITIVE_NUMBER = " \\+?\\d+";
/**
* Parse a single line of user input into one command.
* @param command user input line
* @return a fully specified command object
*/
public static Command getCommand(final String command) {
if (command.startsWith(ADD_TRACK)) {
String arguments = command.substring(ADD_TRACK.length());

View File

@ -4,12 +4,25 @@ import edu.kit.informatik.CoachType;
import edu.kit.informatik.ModelRailwaySimulation;
import edu.kit.informatik.Terminal;
/**
* Command used to create a single coach.
*
* @author Arne Keller
* @version 1.0
*/
public class CreateCoach extends Command {
private final CoachType type;
private final int length;
private final boolean couplingFront;
private final boolean couplingBack;
/**
* Create a new 'create coach' command.
* @param type type of the coach
* @param length length of the coach
* @param couplingFront whether the coach should have a front coupling
* @param couplingBack whether the coach should have a back coupling
*/
public CreateCoach(final CoachType type, final int length, final boolean couplingFront, final boolean couplingBack) {
this.type = type;
this.length = length;

View File

@ -2,6 +2,12 @@ package edu.kit.informatik.command;
import edu.kit.informatik.*;
/**
* Command used to create a single engine.
*
* @author Arne Keller
* @version 1.0
*/
public class CreateEngine extends Command {
private final String type;
private final String series;
@ -10,6 +16,15 @@ public class CreateEngine extends Command {
private final boolean couplingFront;
private final boolean couplingBack;
/**
* Construct a new 'create engine' command.
* @param type type of the engine
* @param series series/class of the engine
* @param name name of the engine
* @param length length of the engine
* @param couplingFront whether the new engine should have a front coupling
* @param couplingBack whether the new engine should have a back coupling
*/
public CreateEngine(final String type, final String series, final String name, final int length, final boolean couplingFront, final boolean couplingBack) {
this.type = type;
this.series = series;