Question: In this lab , you will build the The Battle Ship s Game . The Game has a n x n grid and m ships.
In this lab , you will build the The Battle Ship s Game . The Game has a n x n grid and m ships. Each ship takes up exactly three cells. In the game, its you against the computer, but unlike the real battleship game, you dont place any ships on your own. Instead, your job is to sink the computers ship in the fewest number of guess.
Goal:Sink all the computers ships(0
Setup:When the game program is launched, user is again asked to enter whatwould be the size of the grid, that is the value ofn. The value ofnmust bebetween 3and10. Then, the computer placesmships on an x ngrid (for an example, see thefigure below).When thatscomplete the game asks for your first guess.
How to play:We havent learned to build GUI (Graphical User Interface) yet, so thisversion works at the command-line. The computer will prompt you to enter a guess(a cell), that you willtype at the command-line as 1 3(where 1 3 means 3rd cell of the 1strow), 45, etc.. In response to your guess, you will see a result at thecommand line, either Hit, Miss, Kill (or whatever the lucky battleship of the dayis!). When you have sunk all m battleships, the game ends by printing out your rating.
Here is a sample run of the game:
Welcome to the Battle Ships game!
Please enter the size of the grid: 8
Please enter number of ships: 3
Your goal is to sink 3 ships.
Try to sink them all in the fewest number of guesses
Enter a guess [row (1 to 8)] [col (1 to 8)]: 1 3 miss
Enter a guess [row (1 to 8)] [col (1 to 8)]: 2 1 hit
Enter a guess [row(1 to 8)] [col (1 to 8)]: 2 2 miss
Enter a guess [row (1 to 8)] [col (1 to 8)]: 3 1 hit
Enter a guess [row (1 to 8)] [col (1 to 8)]: 4 1 kill
Enter a guess [row (1 to 8)] [col (1 to 8)]: 3 3 miss
Enter a guess [row (1 to 8)] [col (1 to 8)]: 1 7 miss
Enter a guess [row (1 to 8)] [col (1 to 8)]: 4 3 hit
Enter a guess [row (1 to 8)] [col (1 to 8)]: 4 4 hit
Enter a guess [row (1 to 8)] [col (1 to 8)]: 4 5 kill
Enter a guess [row (1 to 8)] [col (1 to 8)]: 5 1 miss
Enter a guess [row (1 to 8)] [col (1 to 8)]: 3 1 miss
Enter a guess [row (1 to 8)] [col (1 to 8)]: 6 1 miss
Enter a guess [row (1 to 8)] [col (1 to 8)]: 61 1 miss
Enter a guess [row (1 to 8)] [col (1 to 8)]: 6 1 miss
Enter a guess [row (1 to 8)] [col (1 to 8)]: 8 4 hit
Enter a guess [row (1 to 8)] [col (1 to 8)]: 8 5 hit
Enter a guess [row (1 to 8)] [col (1 to 8)]: 8 6 kill
All ships are sank!
It only took you18 guesses.
You got out before your options sank.
When player can finish the game within 20 guesses,print the following message (where xx is the number of guesses):
All ships are sank! It only took you XX guesses.
You got out before your options sank.
If it takes more than 20 guesses, print the following message All ships are sank! Took you long enough.XX guesses.Fish are dancing with your options.
Your program should term
inate after 25 guesses and
reveal the positions of the
ships.
NOTE: While designing the classes for this lab, you must follow OOP design concepts (Abstraction,Modularity,Inheritance and API design)
i need a UML diagram for the program
and a code for the program in java application
and proper comments for the program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
