Moves a ship around Earth seas. Earth is represented as a grid.
-
Given the initial starting point (x, y) of a ship and the direction (n, s, e, w) it is facing.
-
Implement commands that move the ship forward and backward (f, b).
-
Implement commands that turn the ship left and right (l, r).
-
The ship can receive a string with commands ("lrfb" is equivalent to left, right, forward, backwards).
-
Earth, as any other planet is a sphere. Implement wrapping from one edge of the grid to another.
-
Not the whole planet consists of seas. Roughly 30% is surface are islands and continents. Implement surface detection before each move to a new position.
This is a simple and complete program. It will show you how to write a good unit test.
- JDK 21.
- No system Gradle installation is required. The checked-in Gradle Wrapper downloads and uses the project's Gradle version.
- Run tests and generate a test report (./build/reports/tests/test/index.html).
$ ./gradlew clean testor
- Run tests and generate both test and coverage reports (./build/reports/jacoco/test/html/index.html).
$ ./gradlew clean test jacocoTestReport- Application code can log through the SLF4J API.
- Log4j2 provides a synchronous console logger at runtime. Project logs default to INFO; other libraries default to WARN.
- Override the project log level when needed:
-Dtdd.ship.log.level=DEBUG.
private static final Logger LOGGER = LoggerFactory.getLogger(Ship.class);
LOGGER.info("Executed ship command");