Also: Include in your game a very first option for the player whether or not they want "regular play" or "debug mode". Debug mode will show where the battleships (or killer whales) are located, as well as where the shot hit. (Of course, regular play is ... well, regular play.) This should be very easy to implement using a boolean variable passed to your output functionality. So, the very first prompt/readin your code should be is exactly:
"do you wish to play regular mode or debug mode? (0 for regular, 1 for debug): _"
Doing this will make the graders very happy. And it is important to keep graders happy.
Furthermore, to make grading easy for the graders, your code is to ask player for x- and y-position, two ints separated by a space, to describe their shot. For example, it might look like this:
Please enter an (x,y) coordinate:
3 2
Miss, nearest ship is 3 spaces away.
~~~~~~~~~~
~~~~~~~~~~
~~~x~~~~~~
~~~~~~~~~~
....
Notice that we are counting 0 -> 9 in each direction, with (0, 0) in the upper left corner.
Option 1...
Background: Homer is tired of being a responsible grownup, adding quality to the life of his fellow Springfield citizens with his hard labors (drinking beer), civic involvement (mostly at Moe's Bar drinking beer), contributions to science and the betterment of life (developing new beer recipes while drinking a lot of beer), and donating his time to the government (sitting in the drunk tank due to excessive beer drinking). So, he wants to spend hour upon hour being a dolt playing a stupid "video game" - a curious label on computer games. He wants you to create it. He demands that you use pointers....because he's a jerk!
Parameters for the game: For the game you are to submit, make the board 10 x 10, have 3 ships (or killer whales), and give the player 20 shots.
So, this assignment is going to be a little different. First, I'm using a font color that will surely make you ill. Next, you are given the choice to work one of the two following programming assignments. Work only one! And, this is individual work - no more team work.
Due: Monday, Dec. 7, 2020 at noon 100 pts.
Submit as usual...
The game of Battleship: You are to use a ptr to a ptr to chars to create a 2-dimensional array of characters. How you do this is part of the lecture #3 on ptrs write-up. Put it in a class called battleship. You will need a constructor that will allocate the sea, clear it of plastic trash, fish poop, over-stuffed killer whales and dead penguins, and then randomly place three groups of two 'B's to represent 3 battleships (two consecutive B's either vertical or horizontal represent a battleship) in that 2-D array of chars. The single player of the game will not be able to see or know where these battleships are, but his/her goal is to locate them by guess work (hence, even Homer can play). The class should have a member function called 'play', whereupon the player will be given some fixed number of guesses to place an 'X' in the array trying to "hit" a battleship. If a battleship is hit (meaning that the player's 'X' landed on a 'B'), then the display will show the remaining 'B' and the player is rewarded 10 pts. If an 'X' misses a battleship, then the game has to tell the player how many steps away they are from the nearest 'B' (not the straight line distance, but the number of steps vertical and horizontal, but not the direction). After each placement of an 'X' by the player, the array is output for viewing - only the X's and any hit battleships. The game proceeds until the player's turns are used up. A bonus of 100 pts is awarded if all battleships are hit before the turns are used up.
When coding this up, remember that you are playing with dynamic memory allocation, so don't forget your destructor...and any other pointer tools needed.
Specifications: Warning: This description is going to be sparse. You are to make the necessary decisions to produce a well-written program to accomplish the desired result. We will not lay it all out for you. Some demands will be specified, but you make most of the design decisions.
Here's an interesting idea...you could have the constructor pick a "secret" location for you in the sea (array). And in each turn, after you have taken your shot at finding the battleships, the battleships will take a random shot at finding you!! Hey, turnabout is fair play.
Option 2...
Background: Penguins have had it with those pesky killer whales (a.k.a. Orkas...like the new name makes them special!). So, the penguins have hired a consulting firm to change it up for their population by making the killers the target of their wrath. A new breed of ICBP (that's Inter-Continental Ballistic Penguin) has been bred to deliver hell-fire and brimstone upon the killer whales. They are outfitted with ballistic devices deliverable to the killers. But, like any good warrior, adequate simulation should find out how it's going to go. And, since penguins like to play games, they want you to code up a game they can play to see how their impending battles will end up.
Specifications: Warning: This description is going to be sparse. You are to make the necessary decisions to produce a well-written program to accomplish the desired result. We will not lay it all out for you. Some demands will be specified, but you make most of the design decisions.
Optionals: The above description is the minimum required to earn you a grade in this course for this last homework assignment. But, you don't need to stop there! You can add all sorts of options to the game if you are bored with life. As examples, you could add a constructor to the game that would accept arguments for parameters to set the number of ships to find, the number of attempts the player gets to find the ships, the size of the (square) sea. Let your imagination go wild!!
Good luck!!
The number of turns given and the size of the array will be specified later.
The game of Battleship Orcadeath: You are to use a ptr to a ptr to chars to create a 2-dimensional array of characters. How you do this is part of the lecture #3 on ptrs write-up. Put it in a class called battleship OrcaDeath. You will need a constructor that will allocate the sea, clear it of plastic trash, fish poop, over-stuffed killer whales and dead penguins, and then randomly place three groups of two 'B's 'K's (for Killers) to represent 3 battleships killer whales (two consecutive K's either vertical or horizontal represent a battleship killer whale) in that 2-D array of chars. The single player of the game will not be able to see or know where these battleships killer whales are, but his/her goal is to locate them by guess work (hence, even Homer a penguin can play). The class should have a member function called 'play', whereupon the player will be given some fixed number of guesses to place an 'X' in the array trying to "hit" a battleship killer whale. If a battleship killer whale is hit (meaning that the player's 'X' landed on a 'B' 'K'), then the display will show the remaining 'B' 'K' and the player is rewarded 10 pts. If an 'X' misses a battleship killer whale, then the game has to tell the player how many steps away they are from the nearest 'B' 'K' (not the straight line distance, but the number of steps vertical and horizontal, but not the direction). After each placement of an 'X' by the player, the array is output for viewing - only the X's and any hit battleships killer whales. The game proceeds until the player's turns are used up. A bonus of 100 pts is awarded if all battleships killer whales are hit before the turns are used up.
When coding this up, remember that you are playing with dynamic memory allocation, so don't forget your destructor...and any other pointer tools needed.
The number of turns given and the size of the array will be specified later.
Here's an interesting idea...you could have the constructor pick a "secret" location for you in the sea (array). And in each turn, after you have taken your shot at finding the ships whale, the battleships killer whale will take a random shot at finding you!! Hey, turnabout is fair play.
Optionals: The above description is the minimum required to earn you a grade in this course for this last homework assignment. But, you don't need to stop there! You can add all sorts of options to the game if you are bored with life. As examples, you could add a constructor to the game that would accept arguments for parameters to set the number of ships whales to find, the number of attempts the player gets to find the ships whales, the size of the (square) sea. Let your imagination go wild!!
Good luck!!
Also, we will notify you about the final parameters of this program later via email. But you can certainly code it up now. Only constants should change when we let you know.