Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Battleship Assignment I've been given an assignment (below) for my c++ class. I'm really having a hard time figuring out how to calculate the

C++ Battleship Assignment

I've been given an assignment (below) for my c++ class. I'm really having a hard time figuring out how to calculate the attack on the ENTIRE column and row when you input coordinates as well as outputting your entire column/row attack. I'll post a picture of the code that was given as well as what the output looks like. Another note I would like to add is that when you input your fire coordinates on the board it calculates your input for the column first, then for the row. Again, this battleship game attacks both column and row instead of a set coordinate. Any feedback is greatly appreciated!

You only have to write the bodies for the functions: displayBoard calculateAttack checkGameOver I have provided: main initBoard For this assignment you can change any code you want, I will only grade you on output. I don't mind if you change the functions or simply don't use functions, or you use vectors instead of arrays. I would suggest that functions and arrays are the easiest / most intuitive way to approach the problem, but you don't have to use my functions if you don't want to. I would recommend against modifying initBoard as you will get points off if your game board is not the same as the solution's, even if the program is conceptually correct. The conceptual idea: The user will first enter an integer value which will be used to seed the random number generator, this will ensure the generation of a reliable board. (Every time you start a new program and enter 1253 for the seed value, you should get the same ship layout). the 2-dimensional waterState array represents a game board, which has a certain number (6) of horizontal or vertical boats of length 5 on it. Initially all board spaces are set by initBoard to either W_UNK_BOARD or W_UNK_EMPTY. These values should be displayed by displayBoard to the user as #. (Both are hidden). The user will input a 2-value location to fire an attack. The attack centered on the square will expose and destroy everything on the vertical and horizontal line (this may be easier to explain by running the solution program). The game is over when either all ships are exposed (destroyed) or when the user exhausts the maximum number of turns (10). image text in transcribed 

image text in transcribed

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago