Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this c++ program, can you help me with it? Please follow the instructions. Thank you! Problem Statement In this project you

I need help with this c++ program, can you help me with it?

  • Please follow the instructions.
  • Thank you!

image text in transcribedimage text in transcribedimage text in transcribed
Problem Statement In this project you will focus on the mapping and targeting portions of the Battleship game. In order to simplify your task, there will only be one player. Design and write code to accomplish the following tasks in the order described: 0 Prompt the user to determine what size of game board should be used. The board will always be a square. The user must be able to select sizes in the range of 10x10 up to 20x20. For our purposes, each space on the game board will be known as a "hole". E.g, there are 100 holes in a 10x10 game board. 0 The game board must be labeled across the top with alphabetical characters (A, B, C, D, etc) and the left side will be labeled numerically (1, 2, 3, 4). See this image L? for an illustration of the labeled game board. - Dynamically allocate an array of integers (with the previously requested size) that will be used to represent the state of the game board. 0 Allow the user to place a single ship on the map 0 Ask the user to indicate the length of their new ship (valid inputs are between 2 "holes" and 5 "holes" in length). 0 Prompt the user to specify the coordinates of the ship in Column-Row format. Sample inputs could be E3, or P13 (depending on the size of the board). The given location will indicate the position corresponding to the stern of the ship. 0 Allow the user to indicate the direction of the ship's placement. There are four available choices: North, East, South, and West. 0 Once the ship's location and direction have been established, display the updated game grid and clearly indicate which holes are occupied by the boat. 0 If the boat is too long to t into the requested location, display an error and allow the user to restart the ship placement. 0 Next, allow the user to re torpedoes o Prompt the user to enter the desired torpedo coordinates (e.g. B7) 0 If the specied location contains part of a ship, inform the user that this was a hit. Update the game board so that it visually shows the "hit". 0 If the specied location did not contain any portion of a ship, inform the user that this was a miss. Update the game board so that it visually shows the "miss". 0 If all portions of the ship have been hit, inform the user that the ship was sunk. Your program should now congratulate the user and exit. 0 The user must be allowed to continue ring torpedoes until the ship is sunk. Additional Requirements In addition to the earlier specications, your program must meet these requirements: Your program must display the updated game grid after each action. Game board effects are cumulative (in other words, the ship, the hits, and the misses should all be visible on the board as they are added). Print an error message and recover when the player supplies invalid input. This could be a row/column that doesn't exist ("Cat", -4, 142, etc) or any other nonsensical input. You must not have any global variables (although global constants are acceptable) You must use a dynamically allocated 2-dimensional array to represent the game grid. Your functions need to focus on performing a particular task. In other words, you need to use good modular design. If your function uses more than about 20 lines of code, this may be an indication that the code should be split into multiple functions. If the TA notices that your code is not sufciently modular, you will lose points. Comments, blank lines, and variable declarations do not count towards the 20 line threshold. You must not have memory leaks. Segmentation faults are not allowed (e.g. your program crashes). A B C D E F G H J 1 2 3 4 X 5 XX 6 X X XX 7 X 8 XX X 9 10

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions