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
Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. after the loop terminates, it prints out, on a line by itself and separated by spaces, the sum of all the even integers read, the sum of all the odd integers read, a count of the number of even integers read, and a count of the number of odd integers read, all separated by at least one space. declare any variables that are needed. assume the availability of a variable, stdin, that references a scanner object associated with standard input. that is, stdin = new scanner(system.in); is given.
Answers: 3
question
Computers and Technology, 22.06.2019 15:00
I'm taking a class on how to make a movie, and it offers some apps that would be in the process. the thing is, i don't have any of those ha. if you have any tips on some apps i could use, that would be awesome. i don't have an iphone, so don't suggest any apps like imovie. i know that this is a weird question, but it would be super for me. : )
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
What is used to analyze and summarize your data without graphical support
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings starting from index 0. for each match, add one point to userscore. upon a mismatch, exit the loop using a break statement. assume simonpattern and userpattern are always the same length. ex: the following patterns yield a userscore of 4: simonpattern: rrgbryybgy userpattern: rrgbbrybgy
Answers: 2
You know the right answer?
Battleship. java

assignment:
in a simplified game of battleship, the computer pla...
Questions
question
Biology, 23.04.2020 00:07
question
English, 23.04.2020 00:07
Questions on the website: 13722360