Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE USE JAVA, NO C++ NO C LANGUAGE :( Help with my first year computer science assignment :( Using 2D array, create a game called

PLEASE USE JAVA, NO C++ NO C LANGUAGE :(

Help with my first year computer science assignment :(

Using 2D array, create a game called "Battleship"

"Battleship Part 1

In this assignment we recreate the 2-player game Battleship. This assignment will give you lots of practice with two dimensional arrays. There will be a second part of the assignment that is Assignment 9.

In part 1, we will make a one player version and we will start with our ships in set positions. This makes it easy for you in testing your program, and easy for me to help you. In part 2 we will deal with randomized ship placements.

Battleship starts with two boards for a player. There is a board with the ships location, and a second board for the players guesses. Each guess is marked at a hit or a miss. On the final hit on a ship, the guesser is told that they have sunk the ship.

Here is the Ship Location Board that we will use in Part 1:"

1

2

3

4

5

6

A

2

B

2

3

C

3

D

3

E

F

4

4

4

4

Where the numbers in the grid mean the length of that ship. The ship of length 2 is called the Patrol Boat, of length 3 is the Destroyer and of length 4 is the Battleship.

Then there is the players guess board that would look like this after this series of guesses: C3, A4, D1, B5

1

2

3

4

5

6

A

O

B

X

C

O

D

O

E

F

Here O represents a miss while X represents a hit

You need to ask the user to input guesses in the form of B5 or b5 and say hit or miss. Upon sinking a ship you need to display You sunk the Battleship, or whichever ship was sunk. When the final ship has been sunk, you need to display Game over, You Win!.

In my example, I made a display grid with lines. You dont need to do this. You could simply initialize your guesses matrix with ., and replace them with Xs or Os as needed.

Sample Run #1

Here is my board after the third guess:

B1 is a hit

You sunk the Patrol Boat

ENEMY

1 2 3 4 5 6

___ ___ ___ ___ ___ ___

A |_X_|_O_|___|___|___|___|

B |_X_|___|___|___|___|___|

C |___|___|___|___|___|___|

D |___|___|___|___|___|___|

E |___|___|___|___|___|___|

F |___|___|___|___|___|___|

Please enter a guess in the form 'B5':

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

Optimization And Data Science Trends And Applications 5th Airoyoung Workshop And Airo Phd School 2021 Joint Event

Authors: Adriano Masone ,Veronica Dal Sasso ,Valentina Morandi

1st Edition

3030862887, 978-3030862886

More Books

Students also viewed these Databases questions

Question

9:00 ill IE

Answered: 1 week ago