Skip to content

[US-05] Saving and restoring the game

Ivan Esau requested to merge feature/issue-5-us-05-saving-and-restoring-the into master

Description

Implements save/load functionality for the Battleship game as specified in Issue #5 (closed).

Changes

  • Added GameState class for serializable game state
  • Created SaveService for save/load operations with error handling
  • Added FileUtil utility class for file operations
  • Comprehensive test coverage for all acceptance criteria

Features Implemented

Store complete game state (boards, ship placements, shots, turn, difficulty, time) Hidden information preserved after loading Error handling for missing/corrupted files File location and name selection support Save before load doesn't change game state

Acceptance Criteria Verified

  • If game is saved and loaded right away, all visible parts and internal values are identical
  • If corrupted file is loaded, error is displayed and game remains unchanged
  • If completed game is saved and loaded, it stays finished and waits for new start

Technical Details

  • Uses Java serialization for game state persistence
  • Comprehensive error handling and validation
  • Test coverage for all edge cases
  • Follows layered architecture pattern

Closes #5 (closed)

Merge request reports

Loading