I am trying to make a code, where the points are not working. The points always give an odd number. Can you try it, if you can see a problem, I would love help.
#include <iostream>
#define cls system("cls")
#define pause system("pause")
#include <string>
using namespace std;
class games
{
public:
long double points;
int tictactoe(void);
};
int games::tictactoe(void)
{
int computer, playerint;
string player;
computer = rand()%(2);
cls;
cout << "Heads (h) or Tails (t)?";
cin >> player;
if (player == "t" || player == "T")
{
playerint = 0;
} else if(player == "h" || player == "H")
{
playerint = 1;
}
if (playerint == computer)
{
cls;
cout << "Well done! You Won! +100 Points!" << endl;
pause;
points += 100;
} else
{
cls;
cout << "Sorry! You Lost! -100 Points!" << endl;
pause;
points -= 100;
}
}
int chooser()
{
int selection = 0;
int temp;
games player1;
cls;
cout << "Your Choices:" << endl << "1. Tic Tac Toe" << endl << "5. View Profile" << endl << "0. Exit" << endl << "Your Choice:";
cin >> selection;
if (selection == 1)
{
player1.tictactoe();
} else if (selection == 5){
cls;
cout << "Points: " << player1.points << endl;
pause;
cls;
chooser();
} else if(selection == 0)
{
return 0;
} else {
cls;
chooser();
}
chooser();
}
int main()
{
chooser();
}