(Get Answer)
Expert Answer
ORDER YOUR PAPER NOW
- Getting the ship position from player 1
- Clear screen, display board Your program should clear the screen so player 2 cannot see the coordinate player 1 entered. You can do this by printing a special escape sequence: System.out.print("\033[2J"); Then the program prints an empty board with coordinates. Use periods to denote spaces where no guess has yet occurred. Battleship Assignment Discussion Paper
- Player 2 makes guesses A valid guess is a pair of coordinates from 0 to 9 which have not previously been guessed. If a coordinate is invalid the program reprompts. If the point is invalid (because it was guessed already) the program reprompts for both coordinates. Enter the x value of the guess: xxx Invalid, non-numeric Enter the x value of the guess: 10 Invalid, out of range [0-9] Enter the x value of the guess: 2 Enter the y value of the guess: 7 Then the board is displayed, including the misses remaining.
- Final board display, announce winner After as many as 8 guesses the game will be over (3 hits, 5 misses). If player 1 wins, player 2 will not know the actual position of the ship. So when the game is over the program displays the actual position of the ship. Ship positions that were guessed are denoted by a capital X; positions that were never hit are shown as lower-case x's.
ORDER YOUR PAPER NOW
Non-functional requirements You must represent the game board as a 2-dimensional array of char. You must declare and use a final int boardSize=10, so that it is easy to update the game's size. You must write and use the following functions Battleship Assignment Discussion Paper- boolean isValidShip(int x1, int y1, int x2, int y2) Returns true if the coordinates describe a valid ship, false otherwise
- boolean isValidGuess(int x, int y, char[][] board) Returns true if the given location is valid and has not previously been guessed, false otherwise.
- void printBoard(char[][] board, boolean final) Prints the board as shown in the examples above. If final is false, unguessed ship locations are displayed as periods. If final is true, unguessed ship locations are displayed as lowercase x's. Battleship Assignment Discussion Paper
This question has already been tackled by one of our writers and a good grade recorded. You can equally get high grades by simply making your order for this or any other school assignment that you may have.
Every Student Buys Essays from us, here is why!
Pressed for time to complete assignments or when you feel like you cannot write, you can purchase an essay on our website. Some students also want model papers to use as samples when revising or writing. There are also students who approach our essay writing service to beat deadlines. We handle every type of homework, assignment, and academic writing tasks. You can buy college essays and other assignments here. At a glance, here are some reasons students prefer our website.
100% Original Essays and Papers
You can be sure that you are getting a paper that is custom written based on your instructions. We do not sell papers that are pre-written. Instead, we write every essay from scratch. When you say “write my essay,” we respond by giving you a paper that is 100% original and free of any plagiarism. The essays you purchase from us have never been sold anywhere.
Flexible & Affordable Prices
It does not cost a fortune to get academic writing help on our website. If you have a question from class, place an order, get a discount, and get cheap essay writing services. What you see as the price is what you pay for. There are no any hidden charges. If you need urgent papers, they might cost a little more, but the price is worth the quality you get in the end. Hire a professional academic writer beginning from $13 a page.
Anonymity, Privacy, and Confidentiality
No one will ever know that you purchased an essay or assignment from our website. The essays you buy from us are written by experts. Your data is only used to coordinate the essay writing services you get. No one can access your personal information and data. Go ahead and order an essay from our website. It is safe, secure, and convenient.