Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java program please Boats Each boat is represented by a line of consecutive squares on the board. Boats may not overlap other boats, extend outside
java program please
Boats Each boat is represented by a line of consecutive squares on the board. Boats may not overlap other boats, extend outside the game board, or be placed diagonally. They may be horizontal or vertical. A boat is considered "sunk" when all the squares of the boat have been "hit" by the user. Note: Examples: Valid coordinates for a boat of size 3 are {(0,0),(0,1),(0,2)} and {(1,1), (2,1),(3,1)}. Examples of invalid coordinates are {(0,0),(0,1)), which is invalid because there are not enough points. {(0,0), (0,2),(0,3)} is invalid because the points are not consecutive. {(-1,0), (0,0), (1,0)} is invalid because the first coordinate is out of bounds. Finally, two boats cannot contain the same point because they cannot overlap. After the game board has been sized, the program should place boats randomly on the board. This requires randomly generating a coordinate (?,y) where the boat will be placed as well as randomly choosing whether the boat should be horizontal or vertical. The number and size of boats are defined by the width and height of the game board. Recall the smallest board is 3*3 and the largest board is 10 10. 2, 3 Smallest Dimension Boat Sizes width == 3 or height == 3 2 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started