Skip to content

[US-01] Setting ships somewhere on the board

Ivan Esau requested to merge feature/issue-1-us-01-setting-ships-somewhere- into master

Description

Implements ship placement functionality for the Battleship game as described in issue #1.

Changes

  • Created core model classes: Board, Ship, Coordinate, Direction, Player, Game
  • Implemented ship placement validation with boundary checks and overlap prevention
  • Added comprehensive test coverage for all ship placement scenarios
  • Followed the planned layered architecture with model, service, and view packages

Features Implemented

  • 10x10 game board for each player
  • Standard fleet: Carrier (5), Battleship (4), Cruiser (3), Submarine (3), Destroyer (2)
  • Ship placement validation: boundaries, overlaps, straight placement only
  • Error handling for invalid placements
  • Board state management and ship tracking

Acceptance Criteria Verified

If a ship is placed outside the board, the action should not succeed and an error or similar feedback should appear.

  • Implemented boundary validation in Board.validateShipPlacement()
  • Tested in BoardTest.testPlaceShipOutsideBoundariesHorizontal() and BoardTest.testPlaceShipOutsideBoundariesVertical()

If two ships end up on the same squares, the later placement should not overwrite the earlier one.

  • Implemented overlap detection in Board.validateShipPlacement()
  • Tested in BoardTest.testPlaceShipOverlap()

When all ships have been placed validly, the board can be considered ready and hidden for the opponent.

  • Implemented Board.allShipsPlaced() method
  • Standard fleet management with Board.getStandardFleet()

Technical Details

  • Java 21 with Maven build system
  • JUnit 5 testing framework
  • Layered architecture following MVC pattern
  • Comprehensive test coverage with 70%+ code coverage requirement

Closes #1

Merge request reports

Loading