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

Implementation Summary

This merge request implements the ship placement system for the Battleship game as described in Issue #1.

Features Implemented

Core Ship Placement System:

  • 10x10 game board with proper coordinate system
  • 5 standard ship types: Carrier (5), Battleship (4), Cruiser (3), Submarine (3), Destroyer (2)
  • Horizontal and vertical ship orientation
  • Ship placement validation for board boundaries and overlap prevention

Key Components:

  • Board.java - Manages ship placement and validation
  • Ship.java - Ship entity with position, orientation, and damage tracking
  • Coordinate.java - Grid coordinate system with A1 notation
  • ShipPlacementService.java - Service for ship placement operations
  • Player.java - Player representation with board ownership
  • Game.java - Main game orchestrator

Validation Features:

  • Prevents ships from being placed outside board boundaries
  • Prevents overlapping ship placements
  • Ensures ships are placed straight (horizontal/vertical only)
  • Provides clear error messages for invalid placements

Acceptance Criteria Met: AC1: Ship placed outside board fails with error AC2: Overlapping ships do not overwrite each other
AC3: Board ready when all ships placed and hidden from opponent

Testing

Comprehensive test coverage with AcceptanceCriteriaTest.java:

  • Tests all acceptance criteria from Issue #1
  • Validates ship types and sizes match requirements
  • Ensures ships can only be placed straight (not diagonal)
  • Tests boundary conditions and edge cases

Architecture Alignment

This implementation follows the layered architecture defined in the planning documents:

  • Model Layer: Board, Ship, Player, Coordinate entities
  • Service Layer: ShipPlacementService for business logic
  • CLI Interface: Text-based user interaction for ship placement

Closes #1

Merge request reports

Loading