Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ code for Project 5b Project 5.b 175 points] For this project you will write a couple of classes that could be used to make

C++ code for Project 5b image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Project 5.b 175 points] For this project you will write a couple of classes that could be used to make a program that plays the game Battleship (htt pedia.org/wiklBattleship (game). The Ship class represents a ship that has: . a name (e.g. "my destroyer", "my submarine", "Boaty McBoatface") . a length (the number of squares it occupies) . a damage (how many of its squares have been hit) . a constructor that takes as parameters (in this order): the Ship's name and the Ship's length, which will be used to initialize the corresponding data members. The damage should be initialized to zero. . getMethods for each data member (getName, getLength, getDamage) . a method called takeHit that increments a Ship's damage by one https:/oregontate 17983391 1/3 6/1/2018 Assignment The BBoard class represents a 10x10 grid that holds some number of Ships. It should have: . a 10x10 array of bools (for keeping track of what squares have been attacked) . a 10x10 array of Ship-pointers (for keeping track of which Ships occupy which squares) . a variable that keeps track of the number of ships that remain un-sunk . a constructor that initializes each element of the bool array to false and each element of the Ship-pointer . a method called getAtacksArrayElement that takes a row and column (in that order) and returns the ,a method called getShipsArrayElement that takes a row and column (in that order) and returns the . a method called getNumShipsRemaining that returns how many ships remain un-sunk array to NULL (or nullptr if you prefer) element at that position of the bool array element at that position of the ships array . a method called placeShip that takes as parameters in this order; a Ship object, the row and column of the square of the Ship that is closest to (0, 0), and the Ship's orientation (either R if its squares occupy the same row or 'C' if its squares occupy the same column). I give a couple of examples at the end of

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions