subject

Battleship. java

assignment:
in a simplified game of battleship, the computer places a single 4-unit-long ship at a random location in an 8 x 8 playing field, oriented either vertically or horizontally (at random). the player is given 15 torpedoes to fire at the field. after a torpedo is fired, the map of the field is updated to show whether it was a hit or a miss. the game continues until the player sinks the ship or runs out of torpedoes.
write a program to play this game.
sample run
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .

15 torpedoes remain. fire where? 3 4
hit!

. . . .
. . . .
. . x . .
. . . .
. . . .
. . . .
. . . .
. . . .

14 torpedoes remain. fire where? 8 6
miss!

hint:
use a 2-dimensional array to represent the playing field, with different integers representing different states (0 = empty, no fire; 1 = contains ship, no fire; 2 = empty, fired upon; 3 = contains ship, fired upon). think about what you need to do to prevent the computer from placing parts of its ship outside the bounds of the playing field. multiple matrices may be necessary. don’t forget the api.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:00
Pls do you believe that the use of 3d animation has grown in feature films over the last few years? if so, do you think the trend will continue? what are the forces driving this trend?
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
question
Computers and Technology, 23.06.2019 22:00
Jackson, who works in the finance department of a company, is holding a seminar for other employees on how to file taxes. only three employees sign up to attend the seminar. which device can he use to share his presentation with a group of three employees?
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
Which of the following terms refers to a collection of different types of software that share the goal of infiltrating a computer and making it do something? a- malware b- virus c- spyware d- trojan horse
Answers: 2
You know the right answer?
Battleship. java

assignment:
in a simplified game of battleship, the computer pla...
Questions
question
Mathematics, 29.06.2019 14:00
question
Mathematics, 29.06.2019 14:00
question
Mathematics, 29.06.2019 14:00
question
Health, 29.06.2019 14:00
question
Health, 29.06.2019 14:00