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 17:00
Your computer running windows 10 is doing some very strange things with the operating system. you are fairly certain it is not a hardware issue. you need to try to get further insight into what is going on within the operating system. which tool would be best suited for this?
Answers: 2
question
Computers and Technology, 23.06.2019 01:50
Create a class named majors that includes an enumeration for the six majors offered by a college as follows: acc, chem, cis, eng, his, phys. display the enumeration values for the user, then prompt the user to enter a major. display the college division in which the major falls. acc and cis are in the business division, chem and phys are in the science division, and eng and his are in the humanities division. save the file as majors.java.
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
Respond to the following in three to five sentences. select the workplace skill, habit, or attitude described in this chapter that you believe is most important for being a successful employee.
Answers: 1
You know the right answer?
Battleship. java

assignment:
in a simplified game of battleship, the computer pla...
Questions
question
Mathematics, 17.10.2020 14:01
question
Chemistry, 17.10.2020 14:01
question
Mathematics, 17.10.2020 14:01
question
Chemistry, 17.10.2020 14:01
question
Advanced Placement (AP), 17.10.2020 14:01
Questions on the website: 13722360