Skip to content

awongCM/java-toy-robot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-toy-robot

CI

Toy Robot Challenge — a Java 21 CLI that places and moves a robot on a 5×5 table.

Quick start

Run from stdin

mvn compile exec:java

Enter commands one per line (Robot Challenge spec). End input with a blank line.

PLACE 0,0,NORTH
MOVE
REPORT

Expected output: 0,1,NORTH

Non-interactive example:

printf 'PLACE 0,0,NORTH\nMOVE\nREPORT\n\n' | mvn -q compile exec:java

Run from a file

mvn compile exec:java -Dexec.args="commands.txt"

The file is read line-by-line until the first blank line (same rule as stdin). If no argument is given, the app reads from stdin.

Run tests

mvn test
# Tests run: 78, Failures: 0, Errors: 0, Skipped: 0

Architecture

flowchart LR
    Input[stdin or file] --> Parser[CommandParser]
    Parser --> CLI[TextInputInterface]
    CLI --> Simulator[RobotSimulator]
    Simulator --> Table[Table 5x5]
    Table --> Robot[Robot state]
    Simulator --> Output[REPORT output]
Loading
Layer Package Responsibility
CLI com.andywong.cli Parse command lines, read input, print REPORT
Application com.andywong.application Apply spec semantics (ignore invalid moves/placements)
Domain com.andywong.domain Table bounds, robot state, directions

Main entry point: com.andywong.cli.TextInputInterface

Refactor progress

Phases are tracked in docs/REFACTOR_ROADMAP.md. Summary:

Phase Focus Status
1 Build tooling, parsing, test isolation DonePR #2
2 Spec-aligned behavior, integration tests, file input DonePRs #4–#6
3 Clean architecture (no singletons, layered packages) DonePRs #8–#12
4 Polish (CI, edge-case tests, hardening) DonePRs #14–#17

Phase 4 — Polish

Slice Change
4a GitHub Actions CI (mvn test on push/PR)
4b Parameterized edge-case tests (edges, corners, re-PLACE)
4d README polish and CI badge
4c CommandParseException and error-handling docs

Environment

  • Java 21
  • Maven 3.8+
  • JUnit 5

Documentation

About

Toy Robot Challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages