Skip to content

Instantly share code, notes, and snippets.

@pradeepcheers
Created May 17, 2013 20:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pradeepcheers/5601841 to your computer and use it in GitHub Desktop.
Save pradeepcheers/5601841 to your computer and use it in GitHub Desktop.
First commit PlateauOfRobots
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
<profile default="false" name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="PlateauOfRobots" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="PlateauOfRobots" target="1.6" />
</bytecodeTargetLevel>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<component name="libraryTable">
<library name="Maven: junit:junit-dep:4.10">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit-dep/4.10/junit-dep-4.10.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit-dep/4.10/junit-dep-4.10-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit-dep/4.10/junit-dep-4.10-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.hamcrest:hamcrest-core:1.2.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.2.1/hamcrest-core-1.2.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.2.1/hamcrest-core-1.2.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.2.1/hamcrest-core-1.2.1-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.hamcrest:hamcrest-library:1.2.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-library/1.2.1/hamcrest-library-1.2.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-library/1.2.1/hamcrest-library-1.2.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-library/1.2.1/hamcrest-library-1.2.1-sources.jar!/" />
</SOURCES>
</library>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/src/doc" />
<option name="OPTION_SCOPE" value="protected" />
<option name="OPTION_HIERARCHY" value="true" />
<option name="OPTION_NAVIGATOR" value="true" />
<option name="OPTION_INDEX" value="true" />
<option name="OPTION_SEPARATE_INDEX" value="true" />
<option name="OPTION_DOCUMENT_TAG_USE" value="false" />
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
<option name="OPTION_DEPRECATED_LIST" value="true" />
<option name="OTHER_OPTIONS" />
<option name="HEAP_SIZE" />
<option name="LOCALE" />
<option name="OPEN_IN_BROWSER" value="true" />
<option name="OPTION_INCLUDE_LIBS" value="false" />
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/PlateauOfRobots.iml" filepath="$PROJECT_DIR$/PlateauOfRobots.iml" />
</modules>
</component>
</project>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: junit:junit-dep:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.2.1" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-library:1.2.1" level="project" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.newsinternational.exercise</groupId>
<artifactId>PlateauOfRobots</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.newsinternational.exercise.client.PlateauOfRobotsMainTest</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
</project>
package com.newsinternational.exercise.client;
import com.newsinternational.exercise.Robot;
import com.newsinternational.exercise.exception.InvalidInputException;
import com.newsinternational.exercise.exception.OutOfPlateauBoundaryException;
import com.newsinternational.exercise.implementation.EnvironmentSetUp;
import java.util.Scanner;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Class acts like a client to test code in command line
*/
public class PlateauOfRobotsMainTest {
public static void main(String [] args) throws InvalidInputException {
String reTest;
Scanner input = new Scanner (System.in);
Robot robot;
System.out.println("Please enter Plateau co-ordinates Eg - '5 5':");
try {
EnvironmentSetUp.loadPlateau(input.nextLine());
} catch (InvalidInputException e) {
System.out.println(e.getMessage());
}
EnvironmentSetUp environmentSetUp = new EnvironmentSetUp();
do {
try {
System.out.println("Now enter a Robot position Eg - '5 5 N':");
robot = environmentSetUp.createAndDeployRobot(input.nextLine());
System.out.println("Enter movement instructions Eg - 'LMLMRMM':");
robot.move(input.nextLine());
System.out.println("Current position of Robot is ");
System.out.println(environmentSetUp.getRobot().getPosition().toString());
} catch (InvalidInputException e) {
System.out.println(e.getMessage());
} catch (OutOfPlateauBoundaryException e) {
System.out.println(e.getMessage());
}
System.out.println("Add another Robot? (y/n)");
reTest = input.nextLine();
} while(reTest.equalsIgnoreCase("Y") || reTest.equalsIgnoreCase("YES"));
}
}
package com.newsinternational.exercise.constant;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Class responsible for holding all the constant values
*/
public class Constants {
/**
* Constant string values
*/
public static class StringConstants {
public static final String SEPARATOR = " ";
public static final String PLATEAU_PATTERN = "^[1-9]\\d*\\s[1-9]\\d*$";
public static final String ROBOT_POSITION_PATTERN = "^[1-9]\\d*\\s[1-9]\\d*\\s[neswNESW]$";
public static final String MOVEMENT_INSTRUCTION_PATTERN = "^[lmrLMR]+$";
public static final String LEFT = "L";
public static final String RIGHT = "R";
public static final String MOVE = "M";
}
/**
* Constant integer values
*/
public static class NumberConstants {
public static final int ZERO = 0;
public static final int ONE = 1;
public static final int TWO = 2;
}
/**
* Error messages
*/
public static class ErrorMessages {
public static final String EMPTY_INPUT = "Input is null or empty";
public static final String INCORRECT_PLATEAU_INPUT = "Plateau co-ordinates entered are incorrect";
public static final String INCORRECT_ROBOT_POSITION = "Robot position entered is incorrect";
public static final String INCORRECT_MOVEMENT_INSTRUCTIONS = "Movement instructions entered are incorrect";
public static final String OUT_OF_PLATEAU = "Robot positioned out of Plateau";
}
}
package com.newsinternational.exercise.exception;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Exception Class
*/
public class InvalidInputException extends Exception {
/**
* Constuctor
* @param errorMessage
* @see Exception
*/
public InvalidInputException(String errorMessage) {
super(errorMessage);
}
}
package com.newsinternational.exercise.exception;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Exception Class
*/
public class OutOfPlateauBoundaryException extends Exception {
/**
* Constuctor
* @param errorMessage
* @see Exception
*/
public OutOfPlateauBoundaryException(String errorMessage) {
super(errorMessage);
}
}
package com.newsinternational.exercise.implementation;
import com.newsinternational.exercise.Robot;
import com.newsinternational.exercise.constant.Constants;
import com.newsinternational.exercise.exception.InvalidInputException;
import com.newsinternational.exercise.exception.OutOfPlateauBoundaryException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* To change this template use File | Settings | File Templates.
*/
public class EnvironmentSetUp {
/**
* Perform validation on input
* @return validated input
*/
//Robot instance
private Robot robot;
/**
* Loads plateau co-ordinates input to Plateau Enum.
* @param plateauInput
* @throws InvalidInputException
* @see com.newsinternational.exercise.implementation.PlateauImplementation
*/
public static void loadPlateau(String plateauInput) throws InvalidInputException {
plateauInput = validateInput(plateauInput);
validateInputPattern(plateauInput, Constants.StringConstants.PLATEAU_PATTERN, Constants.ErrorMessages.INCORRECT_PLATEAU_INPUT);
PlateauImplementation.INSTANCE.loadPlateau(plateauInput);
}
/**
* Load Robots starting position
* @param robotPosition
* @throws InvalidInputException, OutOfPlateauBoundaryException
* @see com.newsinternational.exercise.implementation.RobotImplementation
*/
public Robot createAndDeployRobot(String robotPosition) throws InvalidInputException, OutOfPlateauBoundaryException {
robotPosition = validateInput(robotPosition);
if (PlateauImplementation.INSTANCE.isPlateauLoaded()) {
validateInputPattern(robotPosition, Constants.StringConstants.ROBOT_POSITION_PATTERN, Constants.ErrorMessages.INCORRECT_ROBOT_POSITION);
validateBoundary(robotPosition);
robot = new RobotImplementation(robotPosition);
PlateauImplementation.INSTANCE.getRobotsOnPlateau().add(robot);
} else {
throw new InvalidInputException(Constants.ErrorMessages.INCORRECT_ROBOT_POSITION);
}
return robot;
}
/**
* Input validation
* @param input
* @return
* @throws InvalidInputException
*/
static String validateInput(String input) throws InvalidInputException {
if(input == null || input.equalsIgnoreCase(""))
throw new InvalidInputException(Constants.ErrorMessages.EMPTY_INPUT);
return input.toUpperCase();
}
/**
* Validation for input pattern
* @param param
* @param regex
* @param errorMessage
* @throws InvalidInputException
*/
static void validateInputPattern(String param, String regex, String errorMessage) throws InvalidInputException {
Pattern pattern;
Matcher patternMatch;
pattern = Pattern.compile(regex);
patternMatch = pattern.matcher(param);
if(!patternMatch.matches())
throw new InvalidInputException(errorMessage);
}
/**
* Validates the starting position of Robot with the Plateau boundary limit
* @param robotPosition
* @throws OutOfPlateauBoundaryException
*/
static void validateBoundary(String robotPosition) throws OutOfPlateauBoundaryException {
String [] coOrdinates = robotPosition.split(Constants.StringConstants.SEPARATOR);
if (PlateauImplementation.INSTANCE.getxCoOrdinate() < Integer.parseInt(coOrdinates[Constants.NumberConstants.ZERO]))
throw new OutOfPlateauBoundaryException(Constants.ErrorMessages.OUT_OF_PLATEAU);
if (PlateauImplementation.INSTANCE.getyCoOrdinate() < Integer.parseInt(coOrdinates[Constants.NumberConstants.ONE]))
throw new OutOfPlateauBoundaryException(Constants.ErrorMessages.OUT_OF_PLATEAU);
}
// Robot getter method
public Robot getRobot() {
return robot;
}
/**
* Clears environment by undeploying all Robots
*/
public static void clearEnvironment() {
PlateauImplementation.INSTANCE.setRobotsOnPlateau(null);
}
}
package com.newsinternational.exercise.implementation;
import com.newsinternational.exercise.Plateau;
import com.newsinternational.exercise.Robot;
import com.newsinternational.exercise.constant.Constants;
import java.util.ArrayList;
import java.util.List;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Enum responsible for storing Plateau co-ordinates
*/
public enum PlateauImplementation implements Plateau{
//singleton
INSTANCE;
private int xCoOrdinate;
private int yCoOrdinate;
private List<Robot> robotsOnPlateau;
private static boolean isPlateauLoaded = false;
public int getxCoOrdinate() {
return xCoOrdinate;
}
public int getyCoOrdinate() {
return yCoOrdinate;
}
private void setxCoOrdinate(int xCoOrdinate) {
this.xCoOrdinate = xCoOrdinate;
}
private void setyCoOrdinate(int yCoOrdinate) {
this.yCoOrdinate = yCoOrdinate;
}
public List<Robot> getRobotsOnPlateau() {
if(robotsOnPlateau == null)
robotsOnPlateau = new ArrayList<Robot>();
return robotsOnPlateau;
}
public void setRobotsOnPlateau(List<Robot> robotsOnPlateau) {
this.robotsOnPlateau = robotsOnPlateau;
}
/**
* Loads Plateau co-ordinates from the input
* @param plateau
*/
public void loadPlateau(String plateau) {
String [] input = plateau.split(Constants.StringConstants.SEPARATOR);
this.setxCoOrdinate(Integer.parseInt(input[Constants.NumberConstants.ZERO]));
this.setyCoOrdinate(Integer.parseInt(input[Constants.NumberConstants.ONE]));
isPlateauLoaded = true;
}
/**
* Confirms if Plateau co-ordinates are loaded
* @return
*/
public boolean isPlateauLoaded() {
return isPlateauLoaded;
}
public int getRobotCount() {
return robotsOnPlateau.size();
}
}
package com.newsinternational.exercise.implementation;
import com.newsinternational.exercise.constant.Constants;
import com.newsinternational.exercise.utility.Direction;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Class responsible for Holding the position of the Robot on Plateau
*/
public class Position {
// x - co-ordinate
private int xCoOrdinate;
// x - co-ordinate
private int yCoOrdinate;
// direction
private Direction direction;
//constructor
public Position(int xCoOrdinate, int yCoOrdinate, Direction direction) {
this.xCoOrdinate = xCoOrdinate;
this.yCoOrdinate = yCoOrdinate;
this.direction = direction;
}
//constructor
public Position (String robotPosition) {
this.loadRobotPosition(robotPosition);
}
public int getxCoOrdinate() {
return xCoOrdinate;
}
void setxCoOrdinate(int xCoOrdinate) {
this.xCoOrdinate = xCoOrdinate;
}
public int getyCoOrdinate() {
return yCoOrdinate;
}
void setyCoOrdinate(int yCoOrdinate) {
this.yCoOrdinate = yCoOrdinate;
}
public Direction getDirection() {
return direction;
}
void setDirection(Direction direction) {
this.direction = direction;
}
/**
* Method responsible for loading the co-ordinates and the direction of the Robot on Plateau
* @param robotPosition
* @return
*/
public Position loadRobotPosition(String robotPosition) {
String [] input = robotPosition.split(Constants.StringConstants.SEPARATOR);
this.setxCoOrdinate(Integer.parseInt(input[Constants.NumberConstants.ZERO]));
this.setyCoOrdinate(Integer.parseInt(input[Constants.NumberConstants.ONE]));
this.setDirection(Direction.valueOf(input[Constants.NumberConstants.TWO].toUpperCase()));
return this;
}
/**
* Method responsible for displaying the current position of the Robot
* @return
*/
public String toString() {
return Integer.toString(this.getxCoOrdinate()) + Constants.StringConstants.SEPARATOR +
Integer.toString(this.getyCoOrdinate()) + Constants.StringConstants.SEPARATOR +
this.getDirection();
}
}
package com.newsinternational.exercise.implementation;
import com.newsinternational.exercise.Plateau;
import com.newsinternational.exercise.Robot;
import com.newsinternational.exercise.constant.Constants;
import com.newsinternational.exercise.exception.InvalidInputException;
import com.newsinternational.exercise.exception.OutOfPlateauBoundaryException;
import com.newsinternational.exercise.utility.Direction;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
*
* This is a Robot implementation class for the Robot interface with methods such as move and getRobotPosition
*/
public class RobotImplementation implements Robot {
// Holds position of a Robot
private Position position;
// Holds Robot id
private int id;
// Robot counter
private static int count = 0;
/**
* Constructor
* @param robotPosition
* @see com.newsinternational.exercise.implementation.Position
*/
public RobotImplementation(String robotPosition) {
position = new Position(robotPosition); //Holds starting position
id = count++;
}
/**
* Method responsible for robot's movement based on the movement instruction and stores the current position in Position object
* @param movementInstruction
* @see com.newsinternational.exercise.implementation.Position
*/
@Override
public void move(String movementInstruction) throws InvalidInputException, OutOfPlateauBoundaryException {
movementInstruction = EnvironmentSetUp.validateInput(movementInstruction);
if (PlateauImplementation.INSTANCE.isPlateauLoaded()) {
EnvironmentSetUp.validateInputPattern(movementInstruction, Constants.StringConstants.MOVEMENT_INSTRUCTION_PATTERN, Constants.ErrorMessages.INCORRECT_MOVEMENT_INSTRUCTIONS);
} else {
throw new InvalidInputException(Constants.ErrorMessages.INCORRECT_MOVEMENT_INSTRUCTIONS);
}
for(Character character : movementInstruction.toCharArray()) {
if(character.toString().equalsIgnoreCase(Constants.StringConstants.LEFT) || character.toString().equalsIgnoreCase(Constants.StringConstants.RIGHT))
position.setDirection(Direction.getNextDirection(position.getDirection(), character.toString()));
if(character.toString().equalsIgnoreCase(Constants.StringConstants.MOVE))
this.moveCoOrdinates(position.getDirection());
}
}
/**
* Based on the movement instruction direction and boundary limit, decides to move robot
* @param currentDirection
* @throws OutOfPlateauBoundaryException
* @see com.newsinternational.exercise.implementation.Position
*/
private void moveCoOrdinates(Direction currentDirection) throws OutOfPlateauBoundaryException {
int xCoOrdinate = position.getxCoOrdinate();
int yCoOrdinate = position.getyCoOrdinate();
if (currentDirection.equals(Direction.E) && (++xCoOrdinate <= PlateauImplementation.INSTANCE.getxCoOrdinate())) {
position.setxCoOrdinate(xCoOrdinate);
} else if (currentDirection.equals(Direction.W) && (--xCoOrdinate >= Constants.NumberConstants.ZERO)) {
position.setxCoOrdinate(xCoOrdinate);
} else if (currentDirection.equals(Direction.N) && (++yCoOrdinate <= PlateauImplementation.INSTANCE.getyCoOrdinate())) {
position.setyCoOrdinate(yCoOrdinate);
} else if ((currentDirection.equals(Direction.S) && (--yCoOrdinate >= Constants.NumberConstants.ZERO))) {
position.setyCoOrdinate(yCoOrdinate);
} else {
throw new OutOfPlateauBoundaryException(Constants.ErrorMessages.OUT_OF_PLATEAU);
}
}
/**
* Retrieves current position of Robot from Position object
* @return Current position of Robot
*/
@Override
public Position getPosition() {
return position;
}
/**
* Returns Robot's id
* @return
*/
public int getId() {
return id;
}
}
package com.newsinternational.exercise;
import java.util.List;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Interface representing Plateau
*/
public interface Plateau {
// Method for retrieving x-coordinate
public int getxCoOrdinate();
// Method for retrieving y-coordinate
public int getyCoOrdinate();
// List represents list of Robots on Plateau
public List<Robot> getRobotsOnPlateau();
// Used to check if Plateau is loaded
public boolean isPlateauLoaded();
}
package com.newsinternational.exercise;
import com.newsinternational.exercise.exception.InvalidInputException;
import com.newsinternational.exercise.exception.OutOfPlateauBoundaryException;
import com.newsinternational.exercise.implementation.Position;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Interface represents Robot
*/
public interface Robot {
/**
* Robot movement is handled based on the movement instructions to explore Plateau
* @param path
*/
public void move(String path) throws InvalidInputException, OutOfPlateauBoundaryException;
/**
* Retrieves current position of the Robot
*/
public Position getPosition();
}
package com.newsinternational.exercise.utility;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Enum stores directions, retrieving the direction of the Robot based on movement instruction
*/
public enum Direction {
// Enum constant Direction(directionToTheLeft, directionToTheRight)
N("W", "E"),
E("N", "S"),
S("E", "W"),
W("S", "N");
private final String toTheLeft;
private final String toTheRight;
public Direction getToTheLeft() {
return Direction.valueOf(toTheLeft);
}
public Direction getToTheRight() {
return Direction.valueOf(toTheRight);
}
// Constructor
Direction(String left, String right) {
this.toTheLeft = left;
this.toTheRight = right;
}
/**
* Retrieves direction for the Robot based on movement instruction
* @param currentDirection
* @param nextMovement
* @return
*/
public static Direction getNextDirection(Direction currentDirection, String nextMovement) {
return (nextMovement.equalsIgnoreCase("L")) ?
currentDirection.getToTheLeft() :
currentDirection.getToTheRight();
}
}
Manifest-Version: 1.0
Main-Class: com.newsinternational.exercise.RobotGameTest
package com.newsinternational.exercise.implementation;
import com.newsinternational.exercise.exception.InvalidInputException;
import com.newsinternational.exercise.exception.OutOfPlateauBoundaryException;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Tests responsible for testing EnvironmentSetUp
*/
public class EnvironmentSetUpTest {
private EnvironmentSetUp environmentSetUp;
@Before
public void init(){
environmentSetUp = new EnvironmentSetUp();
}
@Test
public void testValidateInputForString() throws InvalidInputException{
assertThat(EnvironmentSetUp.validateInput("1 1 N"), is("1 1 N"));
}
@Test (expected = InvalidInputException.class)
public void testValidateInputForNull() throws InvalidInputException{
String nullValue = null;
assertThat(environmentSetUp.validateInput(nullValue), is(nullValue));
}
@Test (expected = InvalidInputException.class)
public void testValidateInputForEmptyString() throws InvalidInputException{
String nullValue = "";
assertThat(environmentSetUp.validateInput(nullValue), is(""));
}
@Test
public void testValidateInputForAnyString() throws InvalidInputException{
assertThat(environmentSetUp.validateInput("XXXX"), is("XXXX"));
}
@Test
public void testCompleteFlow() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("9 9");
environmentSetUp.createAndDeployRobot("1 1 N").move("RMM");
assertThat("3 1 E", is(environmentSetUp.getRobot().getPosition().toString()));
}
@Test
public void testCompleteFlowOne() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 N").move("LMLMLMLMM");
assertThat("1 3 N", is(environmentSetUp.getRobot().getPosition().toString()));
}
@Test
public void checkLeftDirectFromNorth() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 N").move("L");
assertThat("W", is(environmentSetUp.getRobot().getPosition().getDirection().toString()));
}
@Test
public void checkLeftDirectFromWest() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 W").move("L");
assertThat("S", is(environmentSetUp.getRobot().getPosition().getDirection().toString()));
}
@Test
public void checkLeftDirectFromSouth() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 S").move("L");
assertThat("E", is(environmentSetUp.getRobot().getPosition().getDirection().toString()));
}
@Test
public void checkLeftDirectFromEast() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 E").move("L");
assertThat("N", is(environmentSetUp.getRobot().getPosition().getDirection().toString()));
}
@Test
public void checkRightDirectFromNorth() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 N").move("R");
assertThat("E", is(environmentSetUp.getRobot().getPosition().getDirection().toString()));
}
@Test
public void checkRightDirectFromEast() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 E").move("R");
assertThat("S", is(environmentSetUp.getRobot().getPosition().getDirection().toString()));
}
@Test
public void checkRightDirectFromSouth() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 S").move("R");
assertThat("W", is(environmentSetUp.getRobot().getPosition().getDirection().toString()));
}
@Test
public void checkRightDirectFromWest() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 W").move("R");
assertThat("N", is(environmentSetUp.getRobot().getPosition().getDirection().toString()));
}
@Test
public void checkOneMoveFromNorth() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 N").move("M");
assertThat(3, is(environmentSetUp.getRobot().getPosition().getyCoOrdinate()));
}
@Test
public void checkOneMoveFromSouth() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 S").move("M");
assertThat(1, is(environmentSetUp.getRobot().getPosition().getyCoOrdinate()));
}
@Test
public void checkOneMoveFromEast() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 E").move("M");
assertThat(2, is(environmentSetUp.getRobot().getPosition().getxCoOrdinate()));
}
@Test
public void checkOneMoveFromWest() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 2 W").move("M");
assertThat(0, is(environmentSetUp.getRobot().getPosition().getxCoOrdinate()));
}
@Test (expected = InvalidInputException.class)
public void checkInvalidRobotPositionInput() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 -2 W").move("M");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidRobotPositionInputOne() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("12 W").move("M");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidRobotPositionInputTwo() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("01 -2 W").move("M");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidRobotPositionInputThree() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("3 4.0 S").move("M");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidRobotPositionInputFour() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("1 0 F").move("M");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidRobotPositionInputFive() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("-12 W").move("M");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidPlateauInput() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 05");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidPlateauInputOne() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("05 5");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidPlateauInputTwo() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("-5 5");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidPlateauInputThree() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 -5");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidPlateauInputFour() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("ab ab");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidPlateauInputFive() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("a b");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidMovementInstructionInput() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 5");
environmentSetUp.createAndDeployRobot("5 5 S").move("-M");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidMovementInstructionInputOne() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("05 5");
environmentSetUp.createAndDeployRobot("2 2 S").move("-6");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidMovementInstructionInputTwo() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("-5 5");
environmentSetUp.createAndDeployRobot("2 2 S").move("0");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidMovementInstructionInputThree() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("5 -5");
environmentSetUp.createAndDeployRobot("2 2 S").move("S");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidMovementInstructionInputFour() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("ab ab");
environmentSetUp.createAndDeployRobot("2 2 S").move("LMA");
}
@Test (expected = InvalidInputException.class)
public void checkInvalidMovementInstructionInputFive() throws InvalidInputException, OutOfPlateauBoundaryException {
EnvironmentSetUp.loadPlateau("a b");
environmentSetUp.createAndDeployRobot("2 2 S").move("a");
}
@Test
public void checkCountOfRobotsOnPlateau() throws InvalidInputException, OutOfPlateauBoundaryException{
EnvironmentSetUp.clearEnvironment();
EnvironmentSetUp.loadPlateau("4 4");
EnvironmentSetUp env1 = new EnvironmentSetUp();
env1.createAndDeployRobot("2 1 N");
env1.createAndDeployRobot("3 2 N");
assertThat(2, is(PlateauImplementation.INSTANCE.getRobotCount()));
}
}
package com.newsinternational.exercise.implementation;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Tests for PlateauImplementation class
*/
public class PlateauImplementationTest {
@Test
public void testLoadPlateau() {
PlateauImplementation.INSTANCE.loadPlateau("3 8");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("3 8"));
}
@Test
public void testPlateauLoadOne() {
PlateauImplementation.INSTANCE.loadPlateau("99 99");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("99 99"));
}
@Test
public void testPlateauLoadTwo() {
PlateauImplementation.INSTANCE.loadPlateau("99999 99999");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("99999 99999"));
}
@Test
public void testPlateauLoadThree() {
PlateauImplementation.INSTANCE.loadPlateau("0 0");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("0 0"));
}
@Test
public void testPlateauLoadFour() {
PlateauImplementation.INSTANCE.loadPlateau("123 345");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("123 345"));
}
@Test
public void testPlateauLoadFive() {
PlateauImplementation.INSTANCE.loadPlateau("7654 675678");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("7654 675678"));
}
@Test
public void testPlateauLoadSix() {
PlateauImplementation.INSTANCE.loadPlateau("64 64");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("64 64"));
}
@Test
public void testPlateauLoadSeven() {
PlateauImplementation.INSTANCE.loadPlateau("3 3");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("3 3"));
}
@Test
public void testPlateauLoadEight() {
PlateauImplementation.INSTANCE.loadPlateau("1 1");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("1 1"));
}
@Test
public void testPlateauLoadNine() {
PlateauImplementation.INSTANCE.loadPlateau("99 0");
assertThat(PlateauImplementation.INSTANCE.getxCoOrdinate() + " " +
PlateauImplementation.INSTANCE.getyCoOrdinate(), is("99 0"));
}
}
package com.newsinternational.exercise.implementation;
import com.newsinternational.exercise.Robot;
import com.newsinternational.exercise.exception.InvalidInputException;
import com.newsinternational.exercise.exception.OutOfPlateauBoundaryException;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Tests for RobotImplementation class
*/
public class RobotImplementationTest {
Robot robot;
@Test
public void testRobotInitialPosition() {
robot = new RobotImplementation("1 1 N");
assertThat("1 1 N", is(robot.getPosition().toString()));
}
@Test
public void testRobotInitialPositionTwo() {
robot = new RobotImplementation("99 99 W");
assertThat("99 99 W", is(robot.getPosition().toString()));
}
@Test
public void testRobotInitialPositionThree() {
robot = new RobotImplementation("5 5 e");
assertThat("5 5 E", is(robot.getPosition().toString()));
}
@Test
public void testRobotInitialPositionFour() {
robot = new RobotImplementation("99 99999 s");
assertThat("99 99999 S", is(robot.getPosition().toString()));
}
@Test
public void testRobotInitialPositionFive() {
robot = new RobotImplementation("7 5 S");
assertThat("7 5 S", is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidForOneMoveTestNorth() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
assertThat("5 6 N",is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidForOneMoveTestSouth() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 S");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
assertThat("5 4 S",is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidL() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("1 1 E");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("LLLL");
assertThat("1 1 E",is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidR() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("1 1 E");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("RRRR");
assertThat("1 1 E",is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidSN() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("1 1 S");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("RR");
assertThat("1 1 N",is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidNS() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("1 3 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("LL");
assertThat("1 3 S",is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidThreeMovesSameDirection() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("1 1 E");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("MMM");
assertThat("4 1 E",is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidThreeMovesOppositeDirection() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("LLMMM");
assertThat("5 2 S",is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidMovesLongTest() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("LMMMMMLMMMMMLMMMMMMMLMMMMMMM");
assertThat("7 7 N",is(robot.getPosition().toString()));
}
@Test
public void shouldMoveBeValidMovesLongTestRight() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("RMMRMMMMMRMMMMMMMRMMMMMRMMMMMR");
assertThat("5 5 S",is(robot.getPosition().toString()));
}
@Test
public void shouldOneMoveFromEast() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 E");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("L");
assertThat("N",is(robot.getPosition().getDirection().toString()));
}
@Test
public void shouldOneMoveFromWest() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 W");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("L");
assertThat("S",is(robot.getPosition().getDirection().toString()));
}
@Test
public void shouldOneMoveFromNorth() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("L");
assertThat("W",is(robot.getPosition().getDirection().toString()));
}
@Test
public void shouldOneMoveFromSouth() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 S");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("L");
assertThat("E",is(robot.getPosition().getDirection().toString()));
}
@Test
public void shouldOneRightMoveFromEast() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 E");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("R");
assertThat("S",is(robot.getPosition().getDirection().toString()));
}
@Test
public void shouldOneRightMoveFromWest() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 W");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("R");
assertThat("N",is(robot.getPosition().getDirection().toString()));
}
@Test
public void shouldOneRightMoveFromNorth() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("R");
assertThat("E",is(robot.getPosition().getDirection().toString()));
}
@Test
public void shouldOneRightMoveFromSouth() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 S");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("R");
assertThat("W",is(robot.getPosition().getDirection().toString()));
}
@Test
public void checkPositonFacingNorthMoveForward() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
assertThat("5 6 N",is(robot.getPosition().toString()));
}
@Test
public void checkPositonFacingSouthMoveForward() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 S");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
assertThat("5 4 S",is(robot.getPosition().toString()));
}
@Test
public void checkPositonFacingEastMoveForward() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 E");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
assertThat("6 5 E",is(robot.getPosition().toString()));
}
@Test
public void checkPositonFacingWestMoveForward() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("5 5 W");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
assertThat("4 5 W",is(robot.getPosition().toString()));
}
@Test (expected = OutOfPlateauBoundaryException.class)
public void checkPositonBottomLeftCornerFacingEast() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("0 0 S");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
}
@Test (expected = OutOfPlateauBoundaryException.class)
public void checkPositonTopLeftCornerFacingEast() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("0 7 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
}
@Test (expected = OutOfPlateauBoundaryException.class)
public void checkPositonTopRightCornerFacingEast() throws OutOfPlateauBoundaryException , InvalidInputException {
robot = new RobotImplementation("7 7 N");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
}
@Test (expected = OutOfPlateauBoundaryException.class)
public void checkPositonBottomRightCornerFacingEast() throws OutOfPlateauBoundaryException, InvalidInputException {
robot = new RobotImplementation("7 0 S");
PlateauImplementation.INSTANCE.loadPlateau("7 7");
robot.move("M");
}
}
package com.newsinternational.exercise;
import com.newsinternational.exercise.exception.InvalidInputException;
import com.newsinternational.exercise.exception.OutOfPlateauBoundaryException;
import com.newsinternational.exercise.implementation.EnvironmentSetUp;
import java.util.Scanner;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Class acts like a client to test code in command line
*/
public class RobotGameTest {
public static void main(String [] args) throws InvalidInputException {
String reTest;
Scanner input = new Scanner (System.in);
Robot robot;
System.out.println("Please enter Plateau co-ordinates Eg - '5 5':");
try {
EnvironmentSetUp.loadPlateau(input.nextLine());
} catch (InvalidInputException e) {
System.out.println(e.getMessage());
}
EnvironmentSetUp environmentSetUp = new EnvironmentSetUp();
do {
try {
System.out.println("Now enter a Robot position Eg - '5 5 N':");
robot = environmentSetUp.createAndDeployRobot(input.nextLine());
System.out.println("Enter movement instructions Eg - 'LMLMRMM':");
robot.move(input.nextLine());
System.out.println("Current position of Robot is ");
System.out.println(environmentSetUp.getRobot().getPosition().toString());
} catch (InvalidInputException e) {
System.out.println(e.getMessage());
} catch (OutOfPlateauBoundaryException e) {
System.out.println(e.getMessage());
}
System.out.println("Add another Robot? (y/n)");
reTest = input.nextLine();
} while(reTest.equalsIgnoreCase("Y") || reTest.equalsIgnoreCase("YES"));
}
}
package com.newsinternational.exercise.utility;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* Created with IntelliJ IDEA.
* User: pradeepcheers
* Tests for Direction Enum
*/
public class DirectionTest {
@Test
public void testDirectionInitialisationNorthToRight()
{
assertThat(Direction.N.getToTheRight(), is(Direction.E));
}
@Test
public void testDirectionInitialisationEastToRight()
{
assertThat(Direction.E.getToTheRight(), is(Direction.S));
}
@Test
public void testDirectionInitialisationSouthToRight()
{
assertThat(Direction.S.getToTheRight(), is(Direction.W));
}
@Test
public void testDirectionInitialisationWestToRight()
{
assertThat(Direction.W.getToTheRight(), is(Direction.N));
}
@Test
public void testDirectionInitialisationNorthToLeft()
{
assertThat(Direction.N.getToTheLeft(), is(Direction.W));
}
@Test
public void testDirectionInitialisationEastToLeft()
{
assertThat(Direction.E.getToTheLeft(), is(Direction.N));
}
@Test
public void testDirectionInitialisationSouthToLeft()
{
assertThat(Direction.S.getToTheLeft(), is(Direction.E));
}
@Test
public void testDirectionInitialisationWestToLeft()
{
assertThat(Direction.W.getToTheLeft(), is(Direction.S));
}
@Test
public void testGetNextDirectionOne()
{
assertThat(Direction.getNextDirection(Direction.N,"L"), is(Direction.W));
}
@Test
public void testGetNextDirectionTwo()
{
assertThat(Direction.getNextDirection(Direction.E,"L"), is(Direction.N));
}
@Test
public void testGetNextDirectionThree()
{
assertThat(Direction.getNextDirection(Direction.W,"L"), is(Direction.S));
}
@Test
public void testGetNextDirectionFour()
{
assertThat(Direction.getNextDirection(Direction.S,"L"), is(Direction.E));
}
@Test
public void checkDirectionRight(){
assertThat(Direction.getNextDirection(Direction.S,"R"), is(Direction.W));
}
@Test
public void checkDirectionRightOne(){
assertThat(Direction.getNextDirection(Direction.W,"R"), is(Direction.N));
}
@Test
public void checkDirectionRightTwo(){
assertThat(Direction.getNextDirection(Direction.S,"R"), is(Direction.W));
}
@Test
public void checkDirectionRightThree(){
assertThat(Direction.getNextDirection(Direction.W,"R"), is(Direction.N));
}
@Test
public void checkDirectionRightFour(){
assertThat(Direction.getNextDirection(Direction.N,"R"), is(Direction.E));
}
@Test
public void checkDirectionRightFive(){
assertThat(Direction.getNextDirection(Direction.E,"R"), is(Direction.S));
}
}
����2w
=> ?@
A ?BC
DE
F
GH
IJ
=K
LM NOP
Q NR
STU
IVW
XYZ[\<init>()VCodeLineNumberTableLocalVariableTablethis?Lcom/newsinternational/exercise/client/PlateauOfRobotsMainTest;main([Ljava/lang/String;)Ve@Lcom/newsinternational/exercise/exception/InvalidInputException;HLcom/newsinternational/exercise/exception/OutOfPlateauBoundaryException;args[Ljava/lang/String;reTestLjava/lang/String;inputLjava/util/Scanner;robot&Lcom/newsinternational/exercise/Robot;environmentSetUp@Lcom/newsinternational/exercise/implementation/EnvironmentSetUp; StackMapTable+>HJU
Exceptions
SourceFilePlateauOfRobotsMainTest.java java/util/Scanner] ^_ ` ab-Please enter Plateau co-ordinates Eg - '5 5':c de fg he>com/newsinternational/exercise/exception/InvalidInputException ig>com/newsinternational/exercise/implementation/EnvironmentSetUp(Now enter a Robot position Eg - '5 5 N': jk+Enter movement instructions Eg - 'LMLMRMM':l meCurrent position of Robot is no pqr sgFcom/newsinternational/exercise/exception/OutOfPlateauBoundaryExceptionAdd another Robot? (y/n)Yt uvYES=com/newsinternational/exercise/client/PlateauOfRobotsMainTestjava/lang/Objectjava/lang/SysteminLjava/io/InputStream;(Ljava/io/InputStream;)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)VnextLine()Ljava/lang/String; loadPlateau
getMessagecreateAndDeployRobot:(Ljava/lang/String;)Lcom/newsinternational/exercise/Robot;$com/newsinternational/exercise/RobotmovegetRobot(()Lcom/newsinternational/exercise/Robot; getPosition:()Lcom/newsinternational/exercise/implementation/Position;6com/newsinternational/exercise/implementation/PositiontoStringjava/lang/StringequalsIgnoreCase(Ljava/lang/String;)Z! /*��!" #$ %& ���Y��M��,�� �:�� �� Y� :��,��N��-,���������� :�� ��:�����,�L+����+�����
3ru
3r�!^ " *%3*;,E.M0W2_4r>u6w8�>�:�<�@�D�F�G"R '(w '(� ')�*+�,- �./Em013234&�567 �8�A7O9 :
;<
����2%
 EMPTY_INPUTLjava/lang/String; ConstantValueINCORRECT_PLATEAU_INPUT INCORRECT_ROBOT_POSITION!INCORRECT_MOVEMENT_INSTRUCTIONS"OUT_OF_PLATEAU#<init>()VCodeLineNumberTableLocalVariableTablethis ErrorMessages InnerClassesALcom/newsinternational/exercise/constant/Constants$ErrorMessages;
SourceFileConstants.java $?com/newsinternational/exercise/constant/Constants$ErrorMessagesjava/lang/ObjectInput is null or empty*Plateau co-ordinates entered are incorrect#Robot position entered is incorrect+Movement instructions entered are incorrectRobot positioned out of Plateau1com/newsinternational/exercise/constant/Constants! 
   /*��) 

����2
ZEROI ConstantValueONETWO<init>()VCodeLineNumberTableLocalVariableTablethisNumberConstants InnerClassesCLcom/newsinternational/exercise/constant/Constants$NumberConstants;
SourceFileConstants.java Acom/newsinternational/exercise/constant/Constants$NumberConstantsjava/lang/Object1com/newsinternational/exercise/constant/Constants! 
  /*�� 

����2+
!" SEPARATORLjava/lang/String; ConstantValue#PLATEAU_PATTERN$ROBOT_POSITION_PATTERN%MOVEMENT_INSTRUCTION_PATTERN&LEFT'RIGHT(MOVE)<init>()VCodeLineNumberTableLocalVariableTablethisStringConstants InnerClassesCLcom/newsinternational/exercise/constant/Constants$StringConstants;
SourceFileConstants.java *Acom/newsinternational/exercise/constant/Constants$StringConstantsjava/lang/Object ^[1-9]\d*\s[1-9]\d*$ ^[1-9]\d*\s[1-9]\d*\s[neswNESW]$ ^[lmrLMR]+$LRM1com/newsinternational/exercise/constant/Constants! 
   /*��  
 
����2
 ErrorMessages InnerClassesNumberConstantsStringConstants<init>()VCodeLineNumberTableLocalVariableTablethis3Lcom/newsinternational/exercise/constant/Constants;
SourceFileConstants.java 1com/newsinternational/exercise/constant/Constantsjava/lang/Object?com/newsinternational/exercise/constant/Constants$ErrorMessagesAcom/newsinternational/exercise/constant/Constants$NumberConstantsAcom/newsinternational/exercise/constant/Constants$StringConstants!  3*��
)   
����2
<init>(Ljava/lang/String;)VCodeLineNumberTableLocalVariableTablethis@Lcom/newsinternational/exercise/exception/InvalidInputException; errorMessageLjava/lang/String;
SourceFileInvalidInputException.java >com/newsinternational/exercise/exception/InvalidInputExceptionjava/lang/Exception!>*+��

  
����2
<init>(Ljava/lang/String;)VCodeLineNumberTableLocalVariableTablethisHLcom/newsinternational/exercise/exception/OutOfPlateauBoundaryException; errorMessageLjava/lang/String;
SourceFile"OutOfPlateauBoundaryException.java Fcom/newsinternational/exercise/exception/OutOfPlateauBoundaryExceptionjava/lang/Exception!>*+��

  
����2�
$N
#OPQ
#R ST
SU
SVWX
#YZ
[ #\
S] ^_`
[a
bcd
be
fg
fh
ijk
bl
Sm
nopq
[
Sr
Ssturobot&Lcom/newsinternational/exercise/Robot;<init>()VCodeLineNumberTableLocalVariableTablethis@Lcom/newsinternational/exercise/implementation/EnvironmentSetUp; loadPlateau(Ljava/lang/String;)V plateauInputLjava/lang/String;
ExceptionscreateAndDeployRobot:(Ljava/lang/String;)Lcom/newsinternational/exercise/Robot; robotPosition StackMapTable validateInput&(Ljava/lang/String;)Ljava/lang/String;inputvalidateInputPattern9(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Vparamregex errorMessagepatternLjava/util/regex/Pattern; patternMatchLjava/util/regex/Matcher;vwvalidateBoundary coOrdinates[Ljava/lang/String;GgetRobot(()Lcom/newsinternational/exercise/Robot;clearEnvironment
SourceFileEnvironmentSetUp.java '( 78^[1-9]\d*\s[1-9]\d*$*Plateau co-ordinates entered are incorrect :;x yz ./ {| ^[1-9]\d*\s[1-9]\d*\s[neswNESW]$#Robot position entered is incorrect E/Acom/newsinternational/exercise/implementation/RobotImplementation '/ %& }~ ��>com/newsinternational/exercise/exception/InvalidInputException� ��Input is null or empty ��v �� ��w �| �� ��� ��Fcom/newsinternational/exercise/exception/OutOfPlateauBoundaryExceptionRobot positioned out of Plateau �� ��>com/newsinternational/exercise/implementation/EnvironmentSetUpjava/lang/Objectjava/util/regex/Patternjava/util/regex/MatcherCcom/newsinternational/exercise/implementation/PlateauImplementationINSTANCEELcom/newsinternational/exercise/implementation/PlateauImplementation;isPlateauLoaded()ZgetRobotsOnPlateau()Ljava/util/List;java/util/Listadd(Ljava/lang/Object;)Zjava/lang/StringequalsIgnoreCase(Ljava/lang/String;)Z toUpperCase()Ljava/lang/String;compile-(Ljava/lang/String;)Ljava/util/regex/Pattern;matcher3(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;matchessplit'(Ljava/lang/String;)[Ljava/lang/String;getxCoOrdinate()Ijava/lang/IntegerparseInt(Ljava/lang/String;)IgetyCoOrdinatesetRobotsOnPlateau(Ljava/util/List;)V!#$%&'()/*��*+ ,- ./)K*�K*��*��*"$ &(+ 01234)�H+�L���.+ 
�+� *� Y+� ���*��W� �Y
��*��*"2468:&<9@CD+H,-H5169 278)X*� *�� �Y��*��*P RT+ 916 2:;)�+�N-*�:�� �Y,���*df hjl+4<1=1>1?@ AB6 �CD2E/)�:*�L��+2�� �Y� ���!+2�� �Y� ��*uwy {/}9~+:513FG6 � H2IJ)/*��*�+ ,- K()$��"�*
��LM
����2o K
LM$N
O
P Q R ST
UV
WX
YZ
[
\ ] ^_
` abcINSTANCEELcom/newsinternational/exercise/implementation/PlateauImplementation; xCoOrdinateI yCoOrdinaterobotsOnPlateauLjava/util/List; Signature8Ljava/util/List<Lcom/newsinternational/exercise/Robot;>;isPlateauLoadedZ$VALUESF[Lcom/newsinternational/exercise/implementation/PlateauImplementation;valuesH()[Lcom/newsinternational/exercise/implementation/PlateauImplementation;CodeLineNumberTablevalueOfY(Ljava/lang/String;)Lcom/newsinternational/exercise/implementation/PlateauImplementation;LocalVariableTablenameLjava/lang/String;<init>(Ljava/lang/String;I)Vthis()VgetxCoOrdinate()IgetyCoOrdinatesetxCoOrdinate(I)VsetyCoOrdinategetRobotsOnPlateau()Ljava/util/List; StackMapTable:()Ljava/util/List<Lcom/newsinternational/exercise/Robot;>;setRobotsOnPlateau(Ljava/util/List;)VLocalVariableTypeTable;(Ljava/util/List<Lcom/newsinternational/exercise/Robot;>;)V loadPlateau(Ljava/lang/String;)Vplateauinput[Ljava/lang/String;()Z getRobotCount<clinit>Ljava/lang/Enum<Lcom/newsinternational/exercise/implementation/PlateauImplementation;>;Lcom/newsinternational/exercise/Plateau;
SourceFilePlateauImplementation.java #$$ deCcom/newsinternational/exercise/implementation/PlateauImplementation )f ./   java/util/ArrayList .1 g hij kl 56 76 !"m n3 ./ java/lang/Enum&com/newsinternational/exercise/Plateauclone()Ljava/lang/Object;5(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;java/lang/Stringsplit'(Ljava/lang/String;)[Ljava/lang/String;java/lang/IntegerparseInt(Ljava/lang/String;)Ijava/util/Listsize@1@
!"#$ %&'"
����( )*'5 *���(+  ,-./'1*+��(+ 0123'/*��(+ 043'/*��( + 056'>*��(
$%+076'>*��(
()+089'R*� �*�
Y� � *� �(-.0+ 0:;<='P*+� �(
45+0>  ?@A'n + � M*,2��*,2����(=?ACD+  0 B-CD!E'.��(L+ 0F3'4
*� ��(Q+ 
0G1'?�Y���Y�S���( HIJ
����2c
: ; < =
>?
@A
BC
D
E
@F
GH
IJ
:
K
BL
M
N
O
P
QRS xCoOrdinateI yCoOrdinate direction2Lcom/newsinternational/exercise/utility/Direction;<init>7(IILcom/newsinternational/exercise/utility/Direction;)VCodeLineNumberTableLocalVariableTablethis8Lcom/newsinternational/exercise/implementation/Position;(Ljava/lang/String;)V robotPositionLjava/lang/String;getxCoOrdinate()IsetxCoOrdinate(I)VgetyCoOrdinatesetyCoOrdinate getDirection4()Lcom/newsinternational/exercise/utility/Direction; setDirection5(Lcom/newsinternational/exercise/utility/Direction;)VloadRobotPositionL(Ljava/lang/String;)Lcom/newsinternational/exercise/implementation/Position;input[Ljava/lang/String;toString()Ljava/lang/String;
SourceFile Position.java T    23 U VWX YZ *+ -+ [7\ ]^ 01java/lang/StringBuilder () 6_ `a ,) ./ `b 676com/newsinternational/exercise/implementation/Positionjava/lang/Object()Vjava/lang/Stringsplit'(Ljava/lang/String;)[Ljava/lang/String;java/lang/IntegerparseInt(Ljava/lang/String;)I toUpperCase0com/newsinternational/exercise/utility/DirectionvalueOfF(Ljava/lang/String;)Lcom/newsinternational/exercise/utility/Direction;(I)Ljava/lang/String;append-(Ljava/lang/String;)Ljava/lang/StringBuilder;-(Ljava/lang/Object;)Ljava/lang/StringBuilder;!
 l*�*�*�*-��! "*#$% G *�*+�W�!
" #$ &'() /*��!#" #$*+ >*��!
'("#$,) /*��!+" #$-+ >*��!
/0"#$./ /*��!3" #$01 >*+��!
78"#$23 x*+�M*,2�� *,2��
*,2� � � *�!ACEG(I" *#$*&'#4567 Z0�Y�*����*����*����!Q" 0#$89
����2�
)ST
U (V (W (X
YZ [\
[]^_
Y`a
U
bc
de
dfg
bhi
j
kl
mn
(o
p
q kr
ks
[p
t ku kv
[q
w kxyz
%U{|}position8Lcom/newsinternational/exercise/implementation/Position;idIcount<init>(Ljava/lang/String;)VCodeLineNumberTableLocalVariableTablethisCLcom/newsinternational/exercise/implementation/RobotImplementation; robotPositionLjava/lang/String;move characterLjava/lang/Character;arr$[Clen$i$movementInstruction StackMapTable=~
ExceptionsmoveCoOrdinates5(Lcom/newsinternational/exercise/utility/Direction;)VcurrentDirection2Lcom/newsinternational/exercise/utility/Direction; xCoOrdinate yCoOrdinate getPosition:()Lcom/newsinternational/exercise/implementation/Position;getId()I<clinit>()V
SourceFileRobotImplementation.java 0P6com/newsinternational/exercise/implementation/Position 01 +, /. -. ��� �� �� ^[lmrLMR]+$+Movement instructions entered are incorrect ��>com/newsinternational/exercise/exception/InvalidInputException� ��~ �� ��L ��R ��� �� �FM EF �N �N �H �� �� �H �H �� �HFcom/newsinternational/exercise/exception/OutOfPlateauBoundaryExceptionRobot positioned out of PlateauAcom/newsinternational/exercise/implementation/RobotImplementationjava/lang/Object$com/newsinternational/exercise/Robotjava/lang/Character>com/newsinternational/exercise/implementation/EnvironmentSetUp validateInput&(Ljava/lang/String;)Ljava/lang/String;Ccom/newsinternational/exercise/implementation/PlateauImplementationINSTANCEELcom/newsinternational/exercise/implementation/PlateauImplementation;isPlateauLoaded()ZvalidateInputPattern9(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Vjava/lang/String toCharArray()[CvalueOf(C)Ljava/lang/Character;toString()Ljava/lang/String;equalsIgnoreCase(Ljava/lang/String;)Z getDirection4()Lcom/newsinternational/exercise/utility/Direction;0com/newsinternational/exercise/utility/DirectiongetNextDirectionx(Lcom/newsinternational/exercise/utility/Direction;Ljava/lang/String;)Lcom/newsinternational/exercise/utility/Direction; setDirectiongetxCoOrdinategetyCoOrdinateEequals(Ljava/lang/Object;)ZsetxCoOrdinate(I)VWNsetyCoOrdinateS!()*+,-.
/.012^*�*�Y+��*�Y`���3!#%'45678912/�+�L�� �+
 � � � Y ��+�M,�>6�Z,4�:������*�*��������**��������3. 1359#==?WAmCzE�=�I4>=H:;(c<=+`>..]?.�56�@8A �
B�(C��D %EF2�*��=*��>+�������*���g+� �����*���K+�!�����"�*��#�)+�$�����*��#� �%Y&�'��32 STV'X2ZC\N^e`pb�d�h�k4*�56�GH�I.�J.A �2! D%KL2/*��3t4 56MN2/*��3}4 56OP2��3QR
����2getxCoOrdinate()IgetyCoOrdinategetRobotsOnPlateau()Ljava/util/List; Signature:()Ljava/util/List<Lcom/newsinternational/exercise/Robot;>;isPlateauLoaded()Z
SourceFile Plateau.java&com/newsinternational/exercise/Plateaujava/lang/Object 
 
����2  move(Ljava/lang/String;)V
Exceptions getPosition:()Lcom/newsinternational/exercise/implementation/Position;
SourceFile
Robot.java$com/newsinternational/exercise/Robotjava/lang/Object>com/newsinternational/exercise/exception/InvalidInputExceptionFcom/newsinternational/exercise/exception/OutOfPlateauBoundaryException 

����2Z ?
@A!B
C D
E F
GH
IJ
K
L
M N O P QRN2Lcom/newsinternational/exercise/utility/Direction;ESW toTheLeftLjava/lang/String;
toTheRight$VALUES3[Lcom/newsinternational/exercise/utility/Direction;values5()[Lcom/newsinternational/exercise/utility/Direction;CodeLineNumberTablevalueOfF(Ljava/lang/String;)Lcom/newsinternational/exercise/utility/Direction;LocalVariableTablename getToTheLeft4()Lcom/newsinternational/exercise/utility/Direction;this getToTheRight<init>:(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)Vleftright Signature'(Ljava/lang/String;Ljava/lang/String;)VgetNextDirectionx(Lcom/newsinternational/exercise/utility/Direction;Ljava/lang/String;)Lcom/newsinternational/exercise/utility/Direction;currentDirection nextMovement StackMapTableB<clinit>()VDLjava/lang/Enum<Lcom/newsinternational/exercise/utility/Direction;>;
SourceFileDirection.java !! ST0com/newsinternational/exercise/utility/Direction &U  &'  .VLW XY *+ -+ ./    java/lang/Enumclone()Ljava/lang/Object;5(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;(Ljava/lang/String;I)Vjava/lang/StringequalsIgnoreCase(Ljava/lang/String;)Z@1@@@@ ! "#$"
����% &'$5 *���%(  )*+$2*���%( ,-+$2*���%( ,./$\*+� *-�*��%  ( ,0123 45$V+
� �
*� �*� �%*(678C9:;$�d�Y���Y���Y���Y���Y�SY�SY�SY�S��%  " 3D2<=>
����2�
A~
~ @��
�
��
�����
�
�� ���
� ��
��������
��
����������
��
��
���������������������
���� ��
����environmentSetUp@Lcom/newsinternational/exercise/implementation/EnvironmentSetUp;<init>()VCodeLineNumberTableLocalVariableTablethisDLcom/newsinternational/exercise/implementation/EnvironmentSetUpTest;initRuntimeVisibleAnnotationsLorg/junit/Before;testValidateInputForString
Exceptions�Lorg/junit/Test;testValidateInputForNull nullValueLjava/lang/String;expected@Lcom/newsinternational/exercise/exception/InvalidInputException;testValidateInputForEmptyStringtestValidateInputForAnyStringtestCompleteFlow�testCompleteFlowOnecheckLeftDirectFromNorthcheckLeftDirectFromWestcheckLeftDirectFromSouthcheckLeftDirectFromEastcheckRightDirectFromNorthcheckRightDirectFromEastcheckRightDirectFromSouthcheckRightDirectFromWestcheckOneMoveFromNorthcheckOneMoveFromSouthcheckOneMoveFromEastcheckOneMoveFromWestcheckInvalidRobotPositionInput!checkInvalidRobotPositionInputOne!checkInvalidRobotPositionInputTwo#checkInvalidRobotPositionInputThree"checkInvalidRobotPositionInputFour"checkInvalidRobotPositionInputFivecheckInvalidPlateauInputcheckInvalidPlateauInputOnecheckInvalidPlateauInputTwocheckInvalidPlateauInputThreecheckInvalidPlateauInputFourcheckInvalidPlateauInputFive$checkInvalidMovementInstructionInput'checkInvalidMovementInstructionInputOne'checkInvalidMovementInstructionInputTwo)checkInvalidMovementInstructionInputThree(checkInvalidMovementInstructionInputFour(checkInvalidMovementInstructionInputFivecheckCountOfRobotsOnPlateauenv1
SourceFileEnvironmentSetUpTest.java DE>com/newsinternational/exercise/implementation/EnvironmentSetUp BC1 1 N ��� ��� ��XXXX9 9 �� ��RMM� ��3 1 E �� ��� ��5 51 2 N LMLMLMLMM1 3 NLW ���1 2 WS1 2 SE1 2 ENRM� �� �� ��1 -2 W12 W01 -2 W3 4.0 S1 0 F-12 W5 0505 5-5 55 -5ab aba b5 5 S-M2 2 S-60LMAa �E4 42 1 N3 2 N� �� ��Bcom/newsinternational/exercise/implementation/EnvironmentSetUpTestjava/lang/Object>com/newsinternational/exercise/exception/InvalidInputExceptionFcom/newsinternational/exercise/exception/OutOfPlateauBoundaryException validateInput&(Ljava/lang/String;)Ljava/lang/String;org/hamcrest/core/Isis*(Ljava/lang/Object;)Lorg/hamcrest/Matcher;org/junit/Assert
assertThat+(Ljava/lang/Object;Lorg/hamcrest/Matcher;)V loadPlateau(Ljava/lang/String;)VcreateAndDeployRobot:(Ljava/lang/String;)Lcom/newsinternational/exercise/Robot;$com/newsinternational/exercise/RobotmovegetRobot(()Lcom/newsinternational/exercise/Robot; getPosition:()Lcom/newsinternational/exercise/implementation/Position;6com/newsinternational/exercise/implementation/PositiontoString()Ljava/lang/String; getDirection4()Lcom/newsinternational/exercise/utility/Direction;0com/newsinternational/exercise/utility/Directionjava/lang/IntegervalueOf(I)Ljava/lang/Integer;getyCoOrdinate()IgetxCoOrdinateclearEnvironmentCcom/newsinternational/exercise/implementation/PlateauImplementationINSTANCEELcom/newsinternational/exercise/implementation/PlateauImplementation; getRobotCount!@ABC'DEF/*��GH IJKEF: *�Y���G
 H  IJLMNEF<����G
 H IJOPLQREFOL*�W+�+���G !"HIJSTOPL QUcVWEFQ L*�W+� ���G&'(HIJSTOPL QUcVXEFA*�W
�
���G
,-H IJOPLQYEFc- � *�� �*�������G234,5H -IJOPZLQ[EFc-� *�� �*�������G:;<,=H -IJOPZLQ\EFf0� *�� �*��������GBCD/EH 0IJOPZLQ]EFf0� *�� �*��������GJKL/MH 0IJOPZLQ^EFf0� *�� �*��������GRST/UH 0IJOPZLQ_EFf0� *� � �!*��������GZ[\/]H 0IJOPZLQ`EFf0� *�� "�*��������Gbcd/eH 0IJOPZLQaEFf0� *� � "�*��������Gjkl/mH 0IJOPZLQbEFf0� *�� "�*��������Grst/uH 0IJOPZLQcEFf0� *�� "�!*��������Gz{|/}H 0IJOPZLQdEFh2� *�� #��$*����%�$���G���1�H 2IJOPZLQeEFh2� *�� #��$*����%�$���G���1�H 2IJOPZLQfEFh2� *� � #��$*����&�$���G���1�H 2IJOPZLQgEFh2� *�� #��$*����&�$���G���1�H 2IJOPZLQhEFH� *�'� #��G���H IJOPZL QUcViEFH� *�(� #��G���H IJOPZL QUcVjEFH� *�)� #��G���H IJOPZL QUcVkEFH� *�*� #��G���H IJOPZL QUcVlEFH� *�+� #��G���H IJOPZL QUcVmEFH� *�,� #��G���H IJOPZL QUcVnEF4-� �G
��H IJOPZL QUcVoEF4.� �G
��H IJOPZL QUcVpEF4/� �G
��H IJOPZL QUcVqEF40� �G
��H IJOPZL QUcVrEF41� �G
��H IJOPZL QUcVsEF42� �G
��H IJOPZL QUcVtEFH� *�3� 4��G���H IJOPZL QUcVuEFH.� *�5� 6��G���H IJOPZL QUcVvEFH/� *�5� 7��GH IJOPZL QUcVwEFH0� *�5� ��G   H IJOPZL QUcVxEFH1� *�5� 8��GH IJOPZL QUcVyEFH2� *�5� 9��GH IJOPZL QUcVzEF~2�:;� �Y�L+<� W+=� W�$�>�?�$���G !"#$'1,H2IJ"{COPZLQ|}
����2]
/ 012
034
/
05
67
8
09
:
;<
=>?@ABCDEFGHI<init>()VCodeLineNumberTableLocalVariableTablethisILcom/newsinternational/exercise/implementation/PlateauImplementationTest;testLoadPlateauRuntimeVisibleAnnotationsLorg/junit/Test;testPlateauLoadOnetestPlateauLoadTwotestPlateauLoadThreetestPlateauLoadFourtestPlateauLoadFivetestPlateauLoadSixtestPlateauLoadSeventestPlateauLoadEighttestPlateauLoadNine
SourceFilePlateauImplementationTest.java J KL3 8 MNjava/lang/StringBuilder OP QR QS TP UVW XYZ [\99 99 99999 999990 0123 345 7654 67567864 643 31 199 0Gcom/newsinternational/exercise/implementation/PlateauImplementationTestjava/lang/ObjectCcom/newsinternational/exercise/implementation/PlateauImplementationINSTANCEELcom/newsinternational/exercise/implementation/PlateauImplementation; loadPlateau(Ljava/lang/String;)VgetxCoOrdinate()Iappend(I)Ljava/lang/StringBuilder;-(Ljava/lang/String;)Ljava/lang/StringBuilder;getyCoOrdinatetoString()Ljava/lang/String;org/hamcrest/core/Isis*(Ljava/lang/Object;)Lorg/hamcrest/Matcher;org/junit/Assert
assertThat+(Ljava/lang/Object;Lorg/hamcrest/Matcher;)V! /*��   !d2���Y���� �
�� �� � ��1 2 "#$d2���Y���� �
�� �� � ��1 2 "#%d2���Y���� �
�� �� � �� 1" 2 "#&d2���Y���� �
�� �� � ��&'1) 2 "#'d2���Y���� �
�� �� � ��-.10 2 "#(d2���Y���� �
�� �� � ��4517 2 "#)d2���Y���� �
�� �� � ��;<1> 2 "#*d2���Y���� �
�� �� � ��BC1E 2 "#+d2���Y���� �
�� �� � ��IJ1L 2 "#,d2���Y���� �
�� �� � ��PQ1S 2 "#-.
����2�
7ijk
l 6m no
pq
rs
tuvwxyz{| }~
}�� n���������������������
p�
�q������������robot&Lcom/newsinternational/exercise/Robot;<init>()VCodeLineNumberTableLocalVariableTablethisGLcom/newsinternational/exercise/implementation/RobotImplementationTest;testRobotInitialPositionRuntimeVisibleAnnotationsLorg/junit/Test;testRobotInitialPositionTwotestRobotInitialPositionThreetestRobotInitialPositionFourtestRobotInitialPositionFive$shouldMoveBeValidForOneMoveTestNorth
Exceptions��$shouldMoveBeValidForOneMoveTestSouthshouldMoveBeValidLshouldMoveBeValidRshouldMoveBeValidSNshouldMoveBeValidNS(shouldMoveBeValidThreeMovesSameDirection,shouldMoveBeValidThreeMovesOppositeDirectionshouldMoveBeValidMovesLongTest#shouldMoveBeValidMovesLongTestRightshouldOneMoveFromEastshouldOneMoveFromWestshouldOneMoveFromNorthshouldOneMoveFromSouthshouldOneRightMoveFromEastshouldOneRightMoveFromWestshouldOneRightMoveFromNorthshouldOneRightMoveFromSouth"checkPositonFacingNorthMoveForward"checkPositonFacingSouthMoveForward!checkPositonFacingEastMoveForward!checkPositonFacingWestMoveForward&checkPositonBottomLeftCornerFacingEastexpectedHLcom/newsinternational/exercise/exception/OutOfPlateauBoundaryException;#checkPositonTopLeftCornerFacingEast$checkPositonTopRightCornerFacingEast'checkPositonBottomRightCornerFacingEast
SourceFileRobotImplementationTest.java :;Acom/newsinternational/exercise/implementation/RobotImplementation1 1 N :� 89� ��� ��� ��� ��99 99 W5 5 e5 5 E
99 99999 s
99 99999 S7 5 S5 5 N� ��7 7 ��M ��5 6 N5 5 S5 4 S1 1 ELLLLRRRR1 1 SRR1 3 NLL1 3 SMMM4 1 ELLMMM5 2 SLMMMMMLMMMMMLMMMMMMMLMMMMMMM7 7 NRMMRMMMMMRMMMMMMMRMMMMMRMMMMMRLN ���5 5 WSWER6 5 E4 5 W0 0 S0 7 N7 0 SEcom/newsinternational/exercise/implementation/RobotImplementationTestjava/lang/ObjectFcom/newsinternational/exercise/exception/OutOfPlateauBoundaryException>com/newsinternational/exercise/exception/InvalidInputException(Ljava/lang/String;)V$com/newsinternational/exercise/Robot getPosition:()Lcom/newsinternational/exercise/implementation/Position;6com/newsinternational/exercise/implementation/PositiontoString()Ljava/lang/String;org/hamcrest/core/Isis*(Ljava/lang/Object;)Lorg/hamcrest/Matcher;org/junit/Assert
assertThat+(Ljava/lang/Object;Lorg/hamcrest/Matcher;)VCcom/newsinternational/exercise/implementation/PlateauImplementationINSTANCEELcom/newsinternational/exercise/implementation/PlateauImplementation; loadPlateaumove getDirection4()Lcom/newsinternational/exercise/utility/Direction;0com/newsinternational/exercise/utility/Direction!6789 :;</*��=> ?@A;<T"*�Y��*����� �= !> "?@BCD;<T"*�Y
��
*����� �= !> "?@BCE;<T"*�Y �� *����� �=# $!%> "?@BCF;<T"*�Y ��*����� �=) *!+> "?@BCG;<T"*�Y��*����� �=/ 0!1> "?@BCH;<o5*�Y����*��*����� �=5 67 849> 5?@IJKBCL;<o5*�Y����*��*����� �== >? @4A> 5?@IJKBCM;<o5*�Y����*��*����� �=E FG H4I> 5?@IJKBCN;<o5*�Y����*��*����� �=M NO P4Q> 5?@IJKBCO;<o5*�Y����*��*����� �=U VW X4Y> 5?@IJKBCP;<o5*�Y����*�� *����� �=] ^_ `4a> 5?@IJKBCQ;<o5*�Y����*�!�"*����� �=e fg h4i> 5?@IJKBCR;<o5*�Y����*�#�$*����� �=m no p4q> 5?@IJKBCS;<o5*�Y����*�%�&*����� �=u vw x4y> 5?@IJKBCT;<o5*�Y����*�'�*����� �=} ~ �4�> 5?@IJKBCU;<r8*�Y ����*�(�)*���*�+�� �=� �� �7�> 8?@IJKBCV;<r8*�Y,����*�(�-*���*�+�� �=� �� �7�> 8?@IJKBCW;<r8*�Y����*�(�.*���*�+�� �=� �� �7�> 8?@IJKBCX;<r8*�Y����*�(�/*���*�+�� �=� �� �7�> 8?@IJKBCY;<r8*�Y ����*�0�-*���*�+�� �=� �� �7�> 8?@IJKBCZ;<r8*�Y,����*�0�)*���*�+�� �=� �� �7�> 8?@IJKBC[;<r8*�Y����*�0�/*���*�+�� �=� �� �7�> 8?@IJKBC\;<r8*�Y����*�0�.*���*�+�� �=� �� �7�> 8?@IJKBC];<o5*�Y����*��*����� �=� �� �4�> 5?@IJKBC^;<o5*�Y����*��*����� �=� �� �4�> 5?@IJKBC_;<o5*�Y ����*��1*����� �=� �� �4�> 5?@IJKBC`;<o5*�Y,����*��2*����� �=� �� �4�> 5?@IJKBCa;<W!*�Y3����*���=� �� �> !?@IJKB Cbccd;<W!*�Y4����*���=� �� �> !?@IJKB Cbcce;<W!*�Y&����*���=� �� �> !?@IJKB Cbccf;<W!*�Y5����*���=� �� �> !?@IJKB Cbccgh
����2w
=> ?@
A ?BC
DE
F
GH
IJ
=K
LM NOP
Q NR
STU
IVW
XYZ[\<init>()VCodeLineNumberTableLocalVariableTablethis.Lcom/newsinternational/exercise/RobotGameTest;main([Ljava/lang/String;)Ve@Lcom/newsinternational/exercise/exception/InvalidInputException;HLcom/newsinternational/exercise/exception/OutOfPlateauBoundaryException;args[Ljava/lang/String;reTestLjava/lang/String;inputLjava/util/Scanner;robot&Lcom/newsinternational/exercise/Robot;environmentSetUp@Lcom/newsinternational/exercise/implementation/EnvironmentSetUp; StackMapTable+>HJU
Exceptions
SourceFileRobotGameTest.java java/util/Scanner] ^_ ` ab-Please enter Plateau co-ordinates Eg - '5 5':c de fg he>com/newsinternational/exercise/exception/InvalidInputException ig>com/newsinternational/exercise/implementation/EnvironmentSetUp(Now enter a Robot position Eg - '5 5 N': jk+Enter movement instructions Eg - 'LMLMRMM':l meCurrent position of Robot is no pqr sgFcom/newsinternational/exercise/exception/OutOfPlateauBoundaryExceptionAdd another Robot? (y/n)Yt uvYES,com/newsinternational/exercise/RobotGameTestjava/lang/Objectjava/lang/SysteminLjava/io/InputStream;(Ljava/io/InputStream;)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)VnextLine()Ljava/lang/String; loadPlateau
getMessagecreateAndDeployRobot:(Ljava/lang/String;)Lcom/newsinternational/exercise/Robot;$com/newsinternational/exercise/RobotmovegetRobot(()Lcom/newsinternational/exercise/Robot; getPosition:()Lcom/newsinternational/exercise/implementation/Position;6com/newsinternational/exercise/implementation/PositiontoStringjava/lang/StringequalsIgnoreCase(Ljava/lang/String;)Z! /*��!" #$ %& ���Y��M��,�� �:�� �� Y� :��,��N��-,���������� :�� ��:�����,�L+����+�����
3ru
3r�!^ " *%3*;,E.M0W2_4r>u6w8�>�:�<�@�D�F�G"R '(w '(� ')�*+�,- �./Em013234&�567 �8�A7O9 :
;<
����2N
, -.
-/ -0
12
34 -5 -6
-78
-9:;<<init>()VCodeLineNumberTableLocalVariableTablethis6Lcom/newsinternational/exercise/utility/DirectionTest;'testDirectionInitialisationNorthToRightRuntimeVisibleAnnotationsLorg/junit/Test;&testDirectionInitialisationEastToRight'testDirectionInitialisationSouthToRight&testDirectionInitialisationWestToRight&testDirectionInitialisationNorthToLeft%testDirectionInitialisationEastToLeft&testDirectionInitialisationSouthToLeft%testDirectionInitialisationWestToLefttestGetNextDirectionOnetestGetNextDirectionTwotestGetNextDirectionThreetestGetNextDirectionFourcheckDirectionRightcheckDirectionRightOnecheckDirectionRightTwocheckDirectionRightThreecheckDirectionRightFourcheckDirectionRightFive
SourceFileDirectionTest.java = >? @A B?C DEF GH I? J? KAL LMR4com/newsinternational/exercise/utility/DirectionTestjava/lang/Object0com/newsinternational/exercise/utility/DirectionN2Lcom/newsinternational/exercise/utility/Direction; getToTheRight4()Lcom/newsinternational/exercise/utility/Direction;Eorg/hamcrest/core/Isis*(Ljava/lang/Object;)Lorg/hamcrest/Matcher;org/junit/Assert
assertThat+(Ljava/lang/Object;Lorg/hamcrest/Matcher;)VSW getToTheLeftgetNextDirectionx(Lcom/newsinternational/exercise/utility/Direction;Ljava/lang/String;)Lcom/newsinternational/exercise/utility/Direction;! /*��  >������
 >������
 >������
 >������
$% >�� ����
*+ >�� ����
01 >�� ����
67 >�� ����
<=  @�
� ����
BC !@�
� ����
HI "@�
� ����
NO #@�
� ����
TU $@� � ����
YZ %@� � ����
^_ &@� � ����
cd '@� � ����
hi (@� � ����
mn )@� � ����
qr *+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment