Ok heres the problem ( and no laughing at my code!! )
I need it to change the value of the strokedistance to the holedistance when the strokedistance makes the holedistance less than zero.
Any suggestions, ideas, tips, and it doesnt have to be specific to my problem maybe just to my code , would be appreciated.
int main()
{
char Club =' ';
char Choice =' ';
int StrokeCount = 0;
int StrokeDistance = 0;
int HoleDistance = 280;
srand(int(time(0)));
cout << " Would You Like To Play? Press [Y] to Continue [N] to Exit "<<endl;
cin >> Choice;
cout << endl;
cout << endl;
Choice = toupper(Choice);
while ( Choice == 'Y')
{
do
{
if (StrokeDistance > HoleDistance && HoleDistance != StrokeDistance)
{
StrokeDistance = HoleDistance;
}
HoleDistance = HoleDistance - StrokeDistance;
cout <<"You are " << HoleDistance <<" metres away from the Hole " << endl;
cout << endl;
cout << "Select Club [D]river [I]ron [P]utter : " << endl;
cin >> Club;
cout << endl;
Club = toupper(Club);
switch (Club)
{
case 'D':
StrokeDistance = 80 + rand() % (120 - 80 + 1);
StrokeCount = StrokeCount + 1;
break;
case 'I':
StrokeDistance = 24 + rand() % (36 - 24 + 1);
StrokeCount = StrokeCount + 1;
break;
case 'P':
StrokeDistance = 8 + rand() % (12 - 8 + 1);
StrokeCount = StrokeCount + 1;
break;
default: StrokeCount = StrokeCount + 1;
cout << " Air Swing 0 Metres Travelled "<<endl;
cout << endl;
break;
}
cout <<"The ball travelled " << StrokeDistance <<" metres "<< endl;
cout << endl;
}
while (HoleDistance <=280 && HoleDistance >= 1 && HoleDistance != StrokeDistance );
if (HoleDistance <1 || HoleDistance <0)
{
HoleDistance = 0;
cout <<" Congratulations the Ball is in the Hole!!! " << endl;
cout << endl;
}
}
system("pause");
return 0;
}