Fast Reliable The Class Examined Some Of The Algorithm Steps Needed. Initial Set-up: The Computer Needs A 10 By 10 “ocean” Grid Storing Where Its Boats Are Found. E Answers.
Questions, Assignments & Papers. Get Answers from Premium Tutors.
Register Free Account
Receive help quickly. Choose your own delivery time.
Make questions 100% private & anonymous.
Get quality help from verified tutors.
TOP THE CLASS EXAMINED SOME OF THE ALGORITHM STEPS NEEDED. INITIAL SET-UP: THE COMPUTER NEEDS A 10 BY 10 “OCEAN” GRID STORING WHERE ITS BOATS ARE FOUND. E QUESTIONS
visibility_off Private questions are not visible.
Program 5: Battleship: This program is a one-player version which enables a user to play Battleship with the computer; it will be written as a class g or the computer could read in data for its ocean grid. User communication: Software should be user-friendly. The user refers to a grid square using a March 30 and a column index from 0 to 9. We will write a function maybe void location(char ch int num int& row int& col) which will convert user input to the needed array index values. Before the user inputs a shot (fires a torpedo) the user sees the 10x10 ocean grid with each square showing either ocean a missed shot or a previous hit. The hit square tells which type of ship (1-boat 2-boat 3- boat 4-boat or 5-boat) was hit there. The primary loop: (1) User inputs grid square where torpedo is sent. Increment number of shots. (2) Hit or miss: If it is a tell the user and designate the miss in the grid. (3) If it is a hit tell the user which boat was hit and designate the hit for that boat in the grid. (3a) Test whether the boat was sunk (all positions have been hit); i report it sunk and (3b) test for Game Over (all boats sunk). Repeat the loop until done; report the number of shots made by the user. Design decision: Grid Array – A the class decided to use the following data structures for the project. There will be two parallel arrays for the 10x10 ocean grids: (1) The computer’ the code for “ocean”. The 1-boat position will be an element with the integer 1 in it; the 2-boat position will be two adjacent elements with a 2 in t