# Family Feud!

## Background

• You want a program to track points for two teams on (a simplified) Family Feud game!
• In each round a survey question is given that has been asked to 100 people and the top answers have been recorded
• To start the round, a representative from each team is chosen two play in a “toss-up”
• The survey question is read
• Whichever team’s rep buzzes in and correctly guesses a top answer first, that team gets to guess the rest of the top survey answers
• Points are allotted based on the popularity of the survey answer

## Problem

• You want a program to track points for two teams
• By using a pointer, it is possible to switch to a different team without modifying the code for adjusting a team’s score.
• int team_A_score = 0;
• int team_B_score = 0;
• How would you write code to adjust the score of whichever team wins the toss-up?
• For each of five rounds (i.e., survey questions),
• Prompt for the team that won the toss-up
• Prompt for points to add for each guess
• End the round after three wrong guesses (i.e., 0 points added)
• Print out the winner
• Let’s play the Feud!

## Solution

#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int MATCH_MISS_COUNT = 3;
const int ROUNDS = 2;

string prompt_for_team();
int prompt_for_points();

int main()
{
int team_A_score = 0;
int team_B_score = 0;

// By using a pointer, we can write code to adjust an arbitrary team's score and switch to different teams as necessary.
int * winning_team_score = NULL;

// SIMULATE MULTIPLE ROUNDS
for (int round = 0; round < ROUNDS; round++)
{
// SIMULATE ONE ROUND
// Prompt for the team that won the toss-up (winning_team_score)
string winning_team = prompt_for_team();

if (winning_team == "A")
{
// A pointer must be assigned to the address of a variable
winning_team_score = &team_A_score;
}
else if (winning_team == "B")
{
winning_team_score = &team_B_score;
}

int wrong_guesses = 0;
while (wrong_guesses < 3)
{
// Prompt for points to add for each guess

{
wrong_guesses++;
}
else
{
// We avoid having to duplicate this code for both team A and team B by using a pointer
}

// End the guessing after a certain number of wrong guesses (i.e., 0 points added)
}
cout << "Score at end of round " << round << " is A - " << team_A_score << ", B - " << team_B_score << endl;
}
cout << "Team " << (team_A_score > team_B_score ? "A" : "B") << " WINS!" << endl;
cout << "GAME OVER" << endl;
system("pause");
return 0;
}

/*
Prompt for team that won the toss-up, read the input (no input validation)
@return user input (A or B)
*/
string prompt_for_team()
{
cout << "In the toss-up, which was the winning team (A,B)? ";

}

/*
Prompt for points to be added (no input validation)
@return user input (points)
*/
int prompt_for_points()
{
}