Hey guys.. I have no clue how to fix this.. so this is a game for 2 players and a bot to guess a game between 1-25 and it's working perfectly as far as I can tell, but the only thing I can't seem to accomplish is to present final results for player1,player2 and the bot to see who wins.
because they just give values zero when out of class, please help if you got the time with explanation so I don't get this problem again. thanks in advance <33
if (r=2){
numbergen=(rand()%(y+1-x)+x);
printf("Player 2\n");
for(c=1;c<26;c++){
player2.getinput();
if(num>numbergen){
printf("Too big!! Try again, %d chances left. \n",25-c);}
if(num<numbergen){
printf("Too small!! Try again, %d chances left. \n",25-c);}
if(num==numbergen){
printf("Winner!! you have tried %d Times. \n",c);
break;}} }}}
printf("Player1 has tried %d times, Player2 has tried %d times.\n",o,c);
system("pause");}
};
class botpc{
public :
void iplay(){int x=0,y=25,range=y-x,z;
srand ( time(NULL) );
numbergen=(rand()%(y+1-x)+x);
printf("I will play now\n");
for(u=1;u<26;u++){
z=(rand()%(y+1-x)+x);
if(z>numbergen){
printf("%d is too big,trying again..\n",z);}
if(z<numbergen){
printf("%d is too small, trying again..\n",z);}
if(z==numbergen){
printf("OHHH!! %d is the number!!!",z);
printf("I WON IN %d TIMES!!! \n",u);
break;}
}
if(z!=numbergen){printf("Damn I didn't even get the number wtf..");}
system("pause");}
};
class result{
public:
void revealfinal(){
printf("Final results:\n---------\nPlayer1: %d chances used.\nPlayer2: %d chances used.\nBot: %d chances used.\n--------------------\n",o,c,u);
if(o>c){if(o>u){printf("Congratz Player1!! you won!!");}}
if(c>u){if(c>o){printf("Congratz Player2!! you won!!");}}
if(u>c){if(u>o){printf("Bot won!! Bot beat human!! Get rekt!!");}} system("pause");}
};
class beforeclosing{
public:
void attract(){
printf("Name:swag lord\nE-mail:swaggerino@kappatchino.com\nPhone:+321323134537\nPlease visit our website: www.NoobsDevs.com and use the code 'happynoob' to get a discount..\n");system("pause");}
};
int main(){
Game desc;
desc.game_description();
desc.game_start();
botpc bot;
bot.iplay();
result end;
end.revealfinal();
beforeclosing appeal;
appeal.attract();