March 2018
Intermediate to advanced
324 pages
8h 30m
English
We need to know what the current location of the ship is in order to be able to move it. Moreover, we should also know which direction it is facing: north, south, east, or west. Therefore, the first requirement is the following:
Before we start working on this requirement, let's go through the helper classes that can be used. The Point class holds the x and y coordinates. It has the following constructor:
public Point(int x, int y) {
this.x = x;
this.y = y;
}
Similarly, we have the Direction enum class with the following values:
public enum Direction { NORTH(0, 'N), EAST(1, 'E'), SOUTH(2, ...Read now
Unlock full access