could someone please explain to me what wrong with my do while loop. i made a pokemon game in visual basic for school. i am teaching my self C++. i just started this weekend and wanted to see if i could covert my code over. everything works perfectly without the loop. except with the loop when charizard or blastoises health go below zero it waits for both of them to go below zero it wont stop when one of them hits zero like i want it to.
i know that && is and, and || is or
so howcome }while(BlastoiseHealth > 0 || CharizardHealth > 0); is being treated as and???
//Danny P
//Sunday January 24, 2010
#include <iostream>
using namespace std;
int main()
{
int BlastoiseHealth = 300;
int CharizardHealth = 300;
int FireBlast = 75;
int FlameThrower = 55;
int DragonBreath = 80;
int Thunder = 150;
int IceBeam = 75;
int WaterGun = 85;
int HydroPump = 150;
int Tackle = 70;
string CharizardAttack(" ");
string BlastoiseAttack(" ");
cout << "Created by: Danny P" << endl;
cout << "Compliled on: Sunday January 24, 2010" << endl;
cout << "" << endl;
cout << "Welcome To Pokemon Stadium Written in C++" << endl;
cout << "In this text based demo you control Charizard's and Blastoise's Attacks" << endl;
cout << "At the first prompt type in an attack for Charizard" << endl;
cout << "and vice-versa for Blastoise" << endl << endl;
cout << "Please note that typing in an incorrect attack will result in the termination of";
cout << "this application, the immediate shutdown of your pokedex, and the immediate" << endl;
cout << "Suspension of your pokemon license!!!" << endl;
cout << " " << endl;
cout << "Charizard's health is: 300 ";
cout << " Blastoise's health is: 300 " << endl;
cout << " " << endl;
cout << "your available attacks for charizard are: " << endl;
cout << " " << endl;
cout << "fireblast 75 damage towards blastoise " << endl;
cout << "flamethrower 55 damage towards blastoise " << endl;
cout << "dragonbreath 80 damage towards blastoise " << endl;
cout << "thunder 150 damage towards blastoise " << endl;
cout << " " << endl;
cout << "your available attacks for blastoise are: " << endl;
cout << " " << endl;
cout << "icebeam 75 damage towards charizard " << endl;
cout << "watergun 55 damage towards charizard " << endl;
cout << "hydropump 80 damage towards charizard " << endl;
cout << "tackle 150 damage towards charizard " << endl;
cout << " " << endl;
do {
cout << "Please enter an attack for Charizard: " ;
cin >> CharizardAttack;
if ( CharizardAttack == "fireblast")
{
BlastoiseHealth = (BlastoiseHealth - FireBlast);
cout << endl << "Blastoise's health is now down to: " << BlastoiseHealth << endl;
}
else
{
if ( CharizardAttack == "flamethrower")
{
BlastoiseHealth = (BlastoiseHealth - FlameThrower);
cout << endl << "Blastoise's health is now down to: " << BlastoiseHealth << endl;
}
else
{
if ( CharizardAttack == "dragonbreath")
{
BlastoiseHealth = (BlastoiseHealth - DragonBreath);
cout << endl << "Blastoise's health is now down to: " << BlastoiseHealth << endl;
}
else
{
if ( CharizardAttack == "thunder")
{
BlastoiseHealth = (BlastoiseHealth - Thunder);
cout << endl << "Blastoise's health is now down to: " << BlastoiseHealth << endl;
}
}
}
}
//**************************************************************************************************************************
cout << " " << endl;
cout << "Please enter an attack for Blastoise: " ;
cin >> BlastoiseAttack;
if ( BlastoiseAttack == "watergun")
{
CharizardHealth = (CharizardHealth - WaterGun);
cout << endl << "Charizard's health is now down to: " << CharizardHealth << endl;
}
else
{
if ( BlastoiseAttack == "hydropump")
{
CharizardHealth = (CharizardHealth - HydroPump);
cout << endl << "Charizard's health is now down to: " << CharizardHealth << endl;
}
else
{
if ( BlastoiseAttack == "tackle")
{
CharizardHealth = (CharizardHealth - Tackle);
cout << endl << "Charizard's health is now down to: " << CharizardHealth << endl;
}
else
{
if ( BlastoiseAttack == "tackle")
{
CharizardHealth = (CharizardHealth - Tackle);
cout << endl << "Charizard's health is now down to: " << CharizardHealth << endl;
}
}
}
}
}while(BlastoiseHealth > 0 || CharizardHealth > 0);
system("pause");
return 0;
}