Example #1
0
int main()
{
    //LinkedList <Player*> chain;
    RedRover x;
    //RedRover y;
    //cout << x.getRoster() << x.getTeamB() << x.getTeamA();
    //x.addToRoster("");
    
    x.addToRoster("Juice\n20\n15\nKaylee\n25\n12\nMatt\n15\n20\nAustin\n1\n20\nAdam\n22\n18\nJeff\n15\n12\nSue\n30\n30\nRoy\n100\n100");
    //x.createTeams();
    x.sendSomeoneOver(x.teamAAt(0), x.teamBAt(0));
   // x.addToRoster("Juice\n10\n15\nKate\n5\n5\nRoy\n20\n20");
   // x.rosterReset();
    //cout << x.getRoster();
    //x.addToRoster("Juice\n3\n4");
    bool testing = true;
    int input = 0;
    
while(testing)
{
    menu();
    cin >> input;
    //input = 11;
    
    switch (input)
    {
        case 0:
        {
            cin.ignore();
            string name, str, spd, add;
            cout << "ENTER A NAME: ";
            getline(cin, name);
            cout << "\nENTER STRENGTH: ";
            getline(cin,str);
            cout << "\nENTER SPEED: ";
            getline(cin,spd);
            add = name + "\n" + str + "\n" + spd;
            cout << add;
            x.addToRoster(add);
          break;
        }
        case 1:
        {
            cout << "Roster Size: " << x.getRosterSize() << endl;
            cout << "Team A Size: " << x.getTeamASize() << endl;
            cout << "Team B Size: " << x.getTeamBSize() << endl << endl;
           break;
        }
        case 2:
        {
            cout << "Roster: " << x.getRoster() << endl;
            cout << "Team A: " << x.getTeamA() << endl;
            cout << "Team B: " << x.getTeamB() << endl << endl;
           break;
        }
        case 3:
        {
            int index=0;
            cout << "ENTER INDEX FOR PLAYER ON ROSTER: ";
            cin >> index;
            PlayerInterface* p1 = x.rosterAt(index);
            cout << "\n At index: " << index << " - " << p1->getName() << " Str: " << p1->getStrength()
            << " Spd: " << p1->getSpeed() << endl << endl;
          break;
        }
            
        case 4:
        {
            int index=0;
            cout << "ENTER INDEX FOR PLAYER ON Team A: ";
            cin >> index;
            PlayerInterface* p1 = x.teamAAt(index);
            cout << "\n At index: " << index << " - " << p1->getName() << " Str: " << p1->getStrength()
            << " Spd: " << p1->getSpeed() << endl << endl;
           break;
        }
            
        case 5:
        {
            int index=0;
            cout << "ENTER INDEX FOR PLAYER ON Team B: ";
            cin >> index;
            PlayerInterface* p1 = x.teamBAt(index);
            cout << "\n At index: " << index << " - " << p1->getName() << " Str: " << p1->getStrength()
            << " Spd: " << p1->getSpeed() << endl << endl;
            break;
        }
            
        case 6:
        {
            cout << "SHUFFLING ROSTER***\n";
            x.shuffleRoster();
            cout << "Roster: " << x.getRoster() << endl << endl;
           break;
        }
            
        case 7:
        {
            cout << "CREATING TEAMS***\n";
            x.createTeams();
            cout << "TEAM A: " << x.getTeamA() << endl;
            cout << "TEAM B: " << x.getTeamB() << endl << endl;
           break;
        }
            
        case 8:
        {
            int run_index, def_index;
            char run_team, def_team;
            PlayerInterface* runner;
            PlayerInterface* defender;
            cout << "SEND SOMEONE OVER***\n";
            cout << "TEAM A: " << x.getTeamA() << endl;
            cout << "TEAM B: " << x.getTeamB() << endl << endl;
            cout << "ENTER INDEX FOR RUNNER: ";
            cin >> run_index;
            cout << " TEAM A OR B: ";
            cin >> run_team;
            cout << "\nENTER INDEX FOR DEFENDER: ";
            cin >> def_index;
            cout << " TEAM A OR B: ";
            cin >> def_team;
            if (run_team == 'a')
            {
                runner = x.teamAAt(run_index);
            }
            else
            {
                runner = x.teamBAt(run_index);
            }
            
            if (def_team == 'a')
            {
                defender = x.teamAAt(def_index);
            }
            else
            {
                defender = x.teamBAt(def_index);
            }
            x.sendSomeoneOver(runner, defender);
            cout << endl << "TEAM A: " << x.getTeamA() << endl;
            cout << "TEAM B: " << x.getTeamB() << endl << endl;
            break;
        }
            
        case 9:
        {
            x.teamReset();
            cout << "TEAM A: " << x.getTeamA() << endl;
            cout << "TEAM B: " << x.getTeamB() << endl << endl;
            break;
        }
        case 10:
        {
            x.rosterReset();
            cout << "ROSTER: " << x.getRoster() << endl << endl;
            break;
        }
            
        case 11:
        {
            cout << "auto play\n\n";
            x.autoPlay();
            break;
        }
            
        case 12:
        {
            x.print();
            break;
        }
            
        case 13:
        {
            x.printFromTail();
            break;
        }
            
        case 14:
        {
            testing = false;
            break;
        }
        case 15:
        {
            x.addToRoster("Juice\n20\n15\nKaylee\n25\n12\nMatt\n15\n20\nAustin\n1\n20\nAdam\n22\n18\nJeff\n15\n12\nSue\n30\n30\nRoy\n100\n100");
            break;
        }
            
    }
}

    
    return 0;
}
Example #2
0
int main()
{
	srand(time(0));
	bool flag = true;
	RedRover Red;

	while (flag)
	{

		cout << "\n\n-----------------------------------------\n";
		cout << "WELCOME TO JAKE'S AMAZING RED ROVER GAME!!!\n";
		cout << "-----------------------------------------";

		cout << "\n\n Do you want to: \n";
		cout << "1 - Add list of players to Roster\n";
		cout << "2 - Display all Players in Roster\n";
		cout << "3 - Roster Size\n";
		cout << "4 - Roster At\n";
		cout << "5 - Shuffle Roster\n";
		cout << "6 - Create Teams\n";
		cout << "7 - Show all teams and roster\n";
		cout << "8 - Team Reset\n";
		cout << "9 - Quit\n";
		cout << "10 - Play RedRover\n";

		cout << "\nPick and option: ";

		int option_selection;
		cin >> option_selection;

		string Team1 = "A";
		string Team2 = "B";

		if (!cin.fail())
		{
			if (option_selection == 1)/////Add to Roster
			{
				bool added = Red.addToRoster("Bam 11 5 George 3 14 Jake 44 b3 Bob 5 3 Sam 11 3 Tom 1a 44 Han 1 5 Luke 3 7 R2D2 8 3 C3P0 5 9 Chewbaca 9 6 Leia 10 2 Rand 1 10 Mat 3 9 Perrin 44 b3 Min 5 7 Lews 4 4 Faile 15 44");
			}
			if (option_selection == 2)////Show Roster
			{
				string readout = Red.getRoster();
				cout << readout << endl;
			}
			if (option_selection == 3)////Get Roster Size
			{
				int RostSize = Red.getRosterSize();
				cout << RostSize << endl;
			}
			if (option_selection == 4)////show roster at
			{
				cout << Red.rosterAt(2);

			}
			if (option_selection == 5)////Shuffle
			{
				Red.shuffleRoster();
			}
			if (option_selection == 6)////create teams
			{
				Red.createTeams();
			}
			if (option_selection == 7)////show teams and roster
			{
				string teamAlist = Red.getTeamA();
				string teamBlist = Red.getTeamB();
				string rosterList = Red.getRoster();

				cout << "\nTeam A: " << teamAlist << endl;
				cout << "Team B: " << teamBlist << endl;
				cout << "Roster: " << rosterList << endl;

			}
			if (option_selection == 8)////reset teams
			{
				Red.teamReset();
			}
			if (option_selection == 9)////Quit
			{
				flag = false;
			}
			if (option_selection == 10)////Send Someone Over
			{

				/*
				int randomSelect = rand() % 2;

				if (randomSelect == 0)
				{
					string chosenRunner = Red.choosePlayer(2, "A"); //// 2 means auto pick, 1 means manual pick.
					string chosenDefender = Red.choosePlayer(2, "B");
					cout << chosenRunner << endl;
					cout << chosenDefender << endl;

					int index1 = Red.TAL.findIndex(chosenRunner);
					int index2 = Red.TBL.findIndex(chosenDefender);
					Red.sendSomeoneOver(Red.teamAAt(index1), Red.teamBAt(index2));
				}
				else if (randomSelect == 1)
				{
					string chosenRunner = Red.choosePlayer(2, "B");
					string chosenDefender = Red.choosePlayer(2, "A");
					cout << chosenRunner << endl;
					cout << chosenDefender << endl;

					int index1 = Red.TBL.findIndex(chosenRunner);
					int index2 = Red.TAL.findIndex(chosenDefender);
					Red.sendSomeoneOver(Red.teamBAt(index1), Red.teamAAt(index2));
				}
				*/
				Red.autoPlay();
				
			}
			else
			{

			}

		}
		else
		{
			cout << "\nThat is not a valid option. Please pick a valid option.\n";
			cin.clear();
			cin.ignore();
		}
	
	}



	

	//system("pause");
	return 0;
}