Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedjava 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 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions