Skip to content

probert999/mars-rover

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mars Rover kata

Mars Rover kata using UML, TDD, Java

Overview

Program to move rovers around the surface of Mars, which is represented by a number of plateaus, divided into a grid.

Rovers can land on a plateau at specified grid coordinates with a compass heading set and then receive commands to move to the next grid space or spin left or right to face another direction. Multiple rovers can be placed on the same plateau.

Design

UML Class Diagram

Capcom

  • Takes input and processes commands
  • Creates and manages plateaus
  • Creates and manages rovers
  • Produces status reports

    Plateau

  • Handles coordinate validation requests from rovers
  • Receives and stores position data for rovers on the plateau to ensure no crashes!
  • Handles map (if enabled)

    Rover

  • Receives and executes move and spin commands


    The interactions between the components can be seen the in Sequence Diagram showing the set-up and processing of a move instruction

    Building and Running the application

    Once cloned, the application can be built using the following Maven command:

    mvn compile package

    The unit tests will be executed as part of the build process which produces a jar file in the target directory.


    To run the application, from the command line, enter:

    java -jar target/mars-rover-1.0-SNAPSHOT.jar

    The main method handles console input or the name of file containing instructions be passed as a parameter, e.g.:

    java -jar target/mars-rover-1.0-SNAPSHOT.jar instructions.txt

    Example instruction files in the testdata folder can also be used, e.g.:

    java -jar target/mars-rover-1.0-SNAPSHOT.jar src/test/resources/instructions.txt

    Commands to explore Mars

    All rovers need a plateau to land on, currently only quadrilateral shaped plateaus are supported.

    Create a plateau

    Enter the maximum x and y coordinates of the plateau, e.g.

    10 10

    Creates a 10x10 square with 0,0 coordinate at the bottom left-hand corner
    On successful creation a plateau id will be returned. Multiple plateaus can be created.
    Maximum size for a Quad Plateau is 9999999,9999999

    Create a rover

    To create a rover on the current plateau specify its x and y coordinates and heading, e.g.

    3 5 N

    Creates a rover on the current plateau at coordinates 3,5 with a heading of North. Plateaus can support multiple rovers.

    Move and Spin commands

    Rover move and spin commends are available to enable exploring:

    L - spin left, e.g. if current heading is North, new heading is East
    R - spin right
    M - move one grid position in the direction of the current heading

    A single command can contain multiple move and spin instructions, e.g. LLMMMRMMM

    Other commands

    SWITCH PLATEAU <plateau-id>switch to the plateau specified
    SWITCH ROVER <rover-id>switch to the rover specified and plateau rover is on
    LIST PLATEAUSdisplay a list of all plateaus
    LIST ROVERSdisplay a list of all rovers and their location
    SHOW MAPshow map for the current plateau (if map feature available)
    HIDE MAPhide map for the current plateau
    FINISHexits the console application
    HELPdisplays the help text

    On exit a report of all rover positions is produced.

    Move logic

    Rovers cannot land on or move to the space as another Rover on the same plateau.

    On receipt of a move command the rover calculates its new coordinates and validates the move with the plateau.

    The plateau checks the coordinates are within bounds and the current position of any other rovers. Two rovers cannot share the same coordinates

    Screenshot

    Screenshot

    Future enhancements

  • Different shaped plateaus
  • Flying rover
  • Obstacles on the plateau
  • Disable rover
  • Additional Capcoms
  • About

    Mars Rover tech task - UML, TDD, Java

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published

    Languages