Please note, Sherpa may occasionally provide incomplete or inaccurate information. Always verify critical details and double-check suggested changes before implementation.
Summary of the Problem
The issue requires extending the battleship board size from a range of 6-15 cells to a new range of 6-25 cells. This will involve modifying the relevant parts of the codebase to accept and handle the new dimensions correctly.
Relevant Files
AbstractPlayer.java: This file contains the logic for player actions, including the setup of the board where the height and width are defined.
BattleshipSalvo.java: This is the main controller for the game, which initializes the board dimensions based on user input.
Board.java: This file represents the game board and initializes the coordinates based on the specified height and width.
Player.java: This interface defines the methods that must be implemented by any player, including the setup method that specifies board dimensions.
Changes Required
1. AbstractPlayer.java
Method: setup(int height, int width, Map<ShipType, Integer> specifications)
Change: Update the documentation to reflect the new height and width range of [6, 25].
Code Hint:
/**
* Given the specifications for a BattleSalvo board, return a list of ships with their locations
* on the board.
*
* @param height the height of the board, range: [6, 25] inclusive
* @param width the width of the board, range: [6, 25] inclusive
2. BattleshipSalvo.java
Method: initBoard()
Change: Modify the validation logic to accept heights and widths up to 25.
Change: Ensure that the constructor can handle the new dimensions correctly. No changes are needed in this file, but ensure that the initCoords() method correctly initializes the board based on the new height and width.
4. Player.java
Method: setup(int height, int width, Map<ShipType, Integer> specifications)
Change: Update the method documentation to reflect the new height and width range of [6, 25].
Code Hint:
/**
* Given the specifications for a BattleSalvo board, return a list of ships with their locations
* on the board.
*
* @param height the height of the board, range: [6, 25] inclusive
* @param width the width of the board, range: [6, 25] inclusive
Summary
To implement the requested change, you will need to update the height and width constraints in the AbstractPlayer and BattleshipSalvo classes, ensuring that the new limits are appropriately enforced in the game logic. After making these adjustments, verify that the game behaves correctly with the new board sizes, including any user input validation and ship placement logic.
Summary of the Problem
The issue requires extending the battleship board size from a range of 6-15 cells to a new range of 6-25 cells. This will involve modifying the relevant parts of the codebase to accept and handle the new dimensions correctly.
Relevant Files
Changes Required
1. AbstractPlayer.java
setup(int height, int width, Map<ShipType, Integer> specifications)
2. BattleshipSalvo.java
initBoard()
3. Board.java
public Board(int height, int width)
initCoords()
method correctly initializes the board based on the new height and width.4. Player.java
setup(int height, int width, Map<ShipType, Integer> specifications)
Summary
To implement the requested change, you will need to update the height and width constraints in the
AbstractPlayer
andBattleshipSalvo
classes, ensuring that the new limits are appropriately enforced in the game logic. After making these adjustments, verify that the game behaves correctly with the new board sizes, including any user input validation and ship placement logic.