Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CREATE A PROGRAM IN C++ Your C++ program must contain three files (2 .cpp and 1 .h file). These files should be named as such:

CREATE A PROGRAM IN C++

Your C++ program must contain three files (2 .cpp and 1 .h file). These files should be named as such: Game.cpp, Player.cpp, Player.h. You will be simulating a game of horse in basketball. The rules we will use for our simulation are as follows:

The game must be played with two players. Each player will simulate shooting the basketball. If one player hits their shot while the other misses their shot, the player that missed the shot collects a letter beginning with the letter H of the word HORSE and iterating through each letter for each subsequent miss. o If both players hit their shot, or both miss their shot, then we continue to the next round. The game continues until one player has collected all of the letters necessary to spell the word HORSE at which point that player is declared the loser of the game.

http://www.wikihow.com/Play-Horse-(the-Basketball-Game)

Your goal is to create a program to simulate this game. This game will be turn-based, meaning that one player will go followed by the next, and so on. The game will continue until one player wins. At which point you should prompt the user if they would like to play again (Y|N).

Development Process: You are required to implement the following items as part of this assignment: Your C++ program must contain three files (2 .cpp and 1 .h file). These files should be named as such: Game.cpp, Player.cpp, Player.h. Your Game class must store two Players on the Heap. Your Player class must use a character array to store the word. In the C++ version we will need to manage our memory accordingly no memory leaks! You can use a random number generator to generate whether or not the Player hits the shot lets assume each Player has a 50% shooting percentage as a default value. When a game finishes we should prompt the user if they would like to play again. The options available to them should be Y or N. o If they select Y, then the program should simulate a new game with all new Players. o If they select N, the program should terminate.

Below is example output of what your program should display when executed:

Welcome to the Game of Horse! Player #1: Hit Shot! Player #2: Hit Shot! Player #1: Missed Shot! Player #2: Hit Shot! Player #1: Added an 'H' Player #1: Hit Shot! Player #2: Missed Shot! Player #2: Added an 'H' Player #1: Missed Shot! Player #2: Hit Shot! Player #1: Added an 'O' Player #1: Hit Shot! Player #2: Missed Shot! Player #2: Added an 'O' Player #1: Hit Shot! Player #2: Missed Shot! Player #2: Added an 'R' Player #1: Missed Shot! Player #2: Hit Shot! Player #1: Added an 'R' Player #1: Missed Shot! Player #2: Missed Shot! Player #1: Hit Shot! Player #2: Missed Shot! Player #2: Added an 'S' Player #1: Missed Shot! Player #2: Missed Shot! Player #1: Missed Shot! Player #2: Hit Shot! Player #1: Added an 'S' Player #1: Missed Shot! Player #2: Missed Shot! Player #1: Hit Shot! Player #2: Missed Shot! Player #2: Added an 'E' Player 1 Wins :: Player 2 = HORSE Would you like to play again (Y|N)? :

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

Students also viewed these Databases questions

Question

What does the start( ) method defined by Thread do?

Answered: 1 week ago

Question

1. Explain why evaluation is important.

Answered: 1 week ago