C++ dlaczego te warunki wpisanie w funkcji while nie działąją jak są 3 a działają jak jest tylko jeden np color!=1
linijka 76
#include <iostream>
#include <string>
#include <ctime>
#include <fstream>
using namespace std;
void main_menu(int& main_menu_navigator);
void p_c();
void menu_option1(string& player_name, int& credits, int& color, int& credits_played);
void conditions_option1(string player_name, int credits, int& credits_played);
int main()
{
int main_menu_navigator, credits, color, credits_played = 0;
string player_name;
while (1)
{
main_menu(main_menu_navigator);
switch (main_menu_navigator)
{
case 1:
menu_option1(player_name, credits, color, credits_played);
conditions_option1(player_name, credits, credits_played);
break;
case 2:
//kod
case 3:
//kod
default: break;
}
}
system("PAUSE");
}
void main_menu(int& main_menu_navigator)
{
cout << "ROULETTE GAME" << endl;
cout << "=============" << endl;
cout << "<<MAIN MENU>>" << endl;
cout << "=============" << endl;
cout << "1.Start a new game." << endl;
cout << "2.Coutinue the game." << endl;
cout << "3.Rule section." << endl;
cout << "4.END." << endl;
cout << "Enter: ";
cin >> main_menu_navigator;
system("cls");
return;
}
void p_c()
{
system("PAUSE");
system("cls");
}
void menu_option1(string& player_name, int& credits, int& color, int& credits_played)
{
credits = 50;
cout << "WELCOME IN C++ CASINO." << endl;
cout << "Enter your name: ";
cin >> player_name;
cout << "Good luck and have fun " << player_name << "." << endl;
cout << "Your credits: " << credits << endl;
cout << "Let's start the game!" << endl;
cout << player_name << " choose color : " << endl;
cout << "1.RED" << endl;
cout << "2.GREEN" << endl;
cout << "3.BLUE" << endl;
if (!(cin >> color))
{
cout << player_name << " you can't enter anything other than a number here! " << endl;
cout << "Restart program and try again." << endl;
system("PAUSE");
exit(0);
}
while (color != 1 || color != 2 || color != 3)
{
system("cls");
cout << "This option dosn't exits!" << endl;
cout << player_name << " choose color : " << endl;
cout << "1.RED" << endl;
cout << "2.GREEN" << endl;
cout << "3.BLUE" << endl;
if (!(cin >> color))
{
cout << player_name << "you can't enter anything other than a number here! " << endl;
cout << "Restart program and try again." << endl;
system("PAUSE");
exit(0);
}
}
cout << "How many credits do you want to play? ";
cin >> credits_played;
p_c();
return;
}
void conditions_option1(string player_name, int credits, int& credits_played)
{
while (credits < credits_played || credits_played < 0)
{
system("cls");
cout << player_name << " you have only " << credits << " credits! You can't play for " << credits_played << "!" << endl;
cout << "How many credits do you want to play? " << endl;
cin >> credits_played;
}
}