1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
//CornHole_Program
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int twoPlayers();
int fourPlayers();
const int CORNHOLE = 3;
const int WOODY = 1;
const int FOUL = 0;
int main()
{
char choice;
cout << "Hello! would you like to play singles or doubles?\n";
cout << "For Singles, please press 'A', for Doubles, please press 'B'\n";
cin >> choice;
while (choice != 'A' && choice != 'B')
{
cout << "Invalid selection, Please enter 'A for singles and 'B' for Doubles.\n";
cout << "Your Choice: ";
cin >> choice;
}
if (choice == 'A')
{
cout << "Singles, Have fun!\n";
twoPlayers();
}
else
{
cout << "Doubles, Have fun!\n";
fourPlayers();
}
}
int twoPlayers()
{
string playerOne, playerTwo;
int roundNumber = 0;
int playerOneTotalScore = 0;
int playerTwoTotalScore = 0;
cout << " \n" << " \n" << "______________SINGLES______________\n" << endl;
cout << "Please enter the name for player one and player two.\n";
cout << "Player One: ";
cin.ignore();
getline(cin, playerOne);
cout << "Player Two: ";
getline(cin, playerTwo);
cout << " \n" << playerOne << ", you will be going first." << endl;
while (playerOneTotalScore < 21 && playerTwoTotalScore < 21)
{
int playerOneRoundScore = 0, playerTwoRoundScore = 0;
int p1CornHoleNum = 0, p1WoodyNum = 0, p1FoulNum = 0,
p2CornHoleNum = 0, p2WoodyNum = 0, p2FoulNum = 0;
//Display the Current Round.
roundNumber++;
cout << " \n" << " \n" << " \n" << " \n"
<< "______________" << "ROUND " << roundNumber << "______________"
<< " \n" << " \n" << " \n" << endl;
cout << playerOne << " How many cornholes did you score?" << endl;
cin >> p1CornHoleNum;
playerOneRoundScore += (CORNHOLE * p1CornHoleNum);
cout << playerOne << " How many woodys did you score?" << endl;
cin >> p1WoodyNum;
playerOneRoundScore += (WOODY * p1WoodyNum);
cout << playerOne << " How many of your shots were foul shots?" << endl;
cin >> p1FoulNum;
playerOneRoundScore += (FOUL * p1FoulNum);
cout << " \n" << playerTwo << " How many cornholes did you score?" << endl;
cin >> p2CornHoleNum;
playerTwoRoundScore += (CORNHOLE * p2CornHoleNum);
cout << playerTwo << " How many woodys did you score?" << endl;
cin >> p2WoodyNum;
playerTwoRoundScore += (WOODY * p2WoodyNum);
cout << playerTwo << " How many of your shots were foul shots?" << endl;
cin >> p2FoulNum;
playerTwoRoundScore += (FOUL * p2FoulNum);
if (playerOneRoundScore > playerTwoRoundScore)
{
cout << playerOne << " scored " << (playerOneRoundScore - playerTwoRoundScore)
<< " points this round." << endl;
playerOneTotalScore += playerOneRoundScore;
}
else if (playerTwoRoundScore > playerOneRoundScore)
{
cout << playerTwo << " scored " << (playerTwoRoundScore - playerOneRoundScore)
<< " points this round." << endl;
playerTwoTotalScore += playerTwoRoundScore;
}
else
cout << "Nobody scored this round" << " \n" << " \n" << endl;
}
return 0;
}
int fourPlayers()
{
cout << "Working on it" << endl;
return 0;
}
|