I have created a program that is based off the guess the number. But what ive added is a menu with four options 1 - 1 player 2 - 2 player 3 - high scores 4 - end game. Now I have the two combined at which im sure it will work but i get two erros about "unsigned int" on line 17 and function 'int main(void)' already has a body on line 51. Now i have tried every bit of trouble shooting with this making sure that everything corrisonds with each other and nothing works. So if you could please help me i would greatly appreciate it.
here is the code
#include<iostream>
#include<vector>
#include<algorithm>
#include<ctime>
#include<cstdlib>
using namespace std;
int game();
int main()
{
int yourHealth = 100;
int oppHealth = 100;
int yourAttack;
int oppAttack;
srand(time(0));
while(yourHealth > 0 && oppHealth > 0);
{
cout << "Your health: " << yourHealth << endl;
cout << "opponent's health: " << oppHealth << endl << endl;
system("PAUSE");
system("CLS");
yourAttack = rand() % 5 + 6;
oppAttack = rand() % 5 + 6;
cout << "you hit for " << yourAttack << endl;
cout << "your opponent hit for " << oppAttack << endl;
yourHealth -= oppAttack;
oppHealth -= yourAttack;
system("PAUSE");
system("CLS");
}
if(yourHealth <= 0 && oppHealth <= 0)
cout << "A double knockout!" << endl;
else if(yourHealth > 0)
cout << "you won! Congrats at winning something that took no skill you are now stupid for playing" << endl;
else
cout << "You Lose....and really suck at life" << endl;
cout << endl;
}
int game();
int main()
{
cout << "Menu\n\n";
cout << "P - 1 player\n";
cout << "PP - 2 player\n";
cout << "H - High Scores\n";
cout << "E - Exit\n\n";
char choice;
cout << "Choice: ";
cin >> choice;
switch (choice)
{
case 'p':
case 'P':
{
cout << "Your the only one\n";
game();//call the game function
}
break;
case 'pp':
case 'PP':
{
cout << "2 players it is.\n";
}
break;
case 'h':
case 'H': // so lowercase h can be entered and uppercase a you can also use toupper() google it.
{
cout << "High scores.\n";
}
break;
case 'e':
case 'E':
{
cout << "Exiting..." << endl;
}
break;
default:
{
cout << "You made an illegal choice.\n";
}
break;
}
cin.ignore();
cin.get();
}