#include <iostream>
using namespace std;
void mf_option(int player1, int player2);
void mf_option2(int player1, int player2);
void mf_option3(int player1, int player2);
int main()
{
int player1, player2;
cout << "\n\n\nWlcome to \"Rock Paper Scissor game\"\n";
cout << " Type 0 for rock, 1 for paper , and 2 for scissors\n";
cout << "Player 1, choose 0, 1 or 2: ";
cin >> player1;
system("clear");
cout << " Type 0 for rock, 1 for paper , and 2 for scissors\n";
cout << "Player 2, choose 0, 1 or 2: ";
cin >> player2;
system("clear");
cout << "\n\nplayer 1, you chose " << player1 << " and player 2 you chose " << player2 << "\n\n";
mf_option(player1, player2);
mf_option2(player1, player2);
mf_option3(player1, player2);
return 0;
}
void mf_option(int player1, int player2)
{
int player1, player2;
if (player1 == 0)
{
if (player2 == 0)
cout << "It's a tie!\n\n\n\n";
else if (player2 == 1)
cout << "Paper Beat rock! Player2 wins!\n\n\n\n";
else if (player2 == 2)
cout << "Rock beat scissors! Player 1 wins!\n\n\n\n";
}
}
void mf_option2(int player1, int player2)
{
int player1, player2;
if (player1 == 1)
{
if (player2 == 0)
cout << "Paper beat rock! Player 1 wins!\n\n\n\n";
else if (player2 == 1)
cout << "It's a tie!\n\n\n\n";
else if (player2 == 2)
cout << "Scissors beat paper! Player 2 wins!\n\n\n\n";
}
}
void mf_option3(int player1, int player2)
{
int player1, player2;
if (player1 == 2)
{
if (player2 == 0)
cout << "Rock beat scissors! Player 2 wins!\n\n\n\n";
else if (player2 == 1)
cout << "Scissors beat paper! Player 1 wins!\n\n\n\n";
else if (player2 == 2)
cout << "its a tie!\n\n\n\n";
}
}
when i try to run this program it says that i have a redefinition of formal parameter errors. the error occurs on lines 35, 48, 61. The error is for player1 and player2. can someone also please explain the point of a user defined function