This third assignment will allow you to explore by comparing

This third assignment will allow you to explore (by comparing and contrasting through construction and implementation) two different object-oriented programming languages (C++ and Java). You will be creating two separate programs one written in C++ and one written in Jav For this assignment, we are going to explore how we can use objects to build more expressive and cleaner programs. In honor of the upcoming event that is known as March Madness and the fact that we are in Indiana (the basketball capital of the worldy, you will be simulating a game of horse in basketball. The rules we will use for our simulation are as follo The game must be played with two players. Each player will simulate shooting the basketball. f 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 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 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 OIN) Development Process: For this assignment, all development must take place on the master branch in a private GitHub recommended that you repository. You must add me and all four (4) TA\'s as collaborators. It is strongly commit and push often! We will be checking to make sure that you are actively pushing changes to your repository. You are also required to include the Honor Pledge in each one of your source files (any file that you have written \"code\" in you need to include the Honor Pledge). 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 Java program must contain the following two files: Gamejava and Playerjava. 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 let\'s assume each Player has a 50% shooting percentage as a default v 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 If they select Y, then the program should simulate a new game with all new Players. If they select N. the program should terminate. 1 of 2

Solution

#include <iostream>
#include <cstdlib>
void horseFun();
using namespace std;

int main()
{
char desc=\'y\';
while(desc == \'y\' || desc == \'Y\')
{
   horseFun();
   cout<<\"Would you like to play again (Y|N)? :\";
   cin>>desc;
}
return 0;
}
void horseFun()
{
int p1, p2, v1, v2, miss1, miss2;
char horse[5]={\'H\',\'O\',\'R\',\'S\',\'E\'};
int h1=0, h2=0;
while(h1 != 5 && h2 !=5)
{
//Player 1 Shot
v1= rand() % 100;
if(v1%2 == 0)
{
cout<<\"Player #1: Hit Shot! \ \";
miss1=0;
}
else
{
cout<<\"Player #1: Missed Shot! \ \";
miss1=1;
}
  
v2= rand() % 100;
if(v2%2 == 0)
{
cout<<\"Player #2: Hit Shot! \ \";
miss2=0;
}
else
{
cout<<\"Player #2: Missed Shot! \ \";
miss2=1;
}
if( miss1 == 0 && miss2 ==0 || miss1 ==1 && miss2 ==1)
continue;
else if(miss1 == 0 && miss2 ==1)
{
cout<<\"Player #2: Added an \'\"<<horse[h2]<<\"\'\"<<endl;
h2++;
}
else if(miss1 ==1 && miss2 == 0)
{
cout<<\"Player #1: Added an \'\"<<horse[h1]<<\"\'\"<<endl;
               h1++;
}
   }
   if (h1 ==5 )
   {
       cout<<\"Player 2 Wins :: Player 1 =HORSE\ \";
   }
   else
   {
       cout<<\"Player 1 Wins :: Player 2 =HORSE\ \";
   }
  
}

 This third assignment will allow you to explore (by comparing and contrasting through construction and implementation) two different object-oriented programmin
 This third assignment will allow you to explore (by comparing and contrasting through construction and implementation) two different object-oriented programmin

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site