Skip to content
Permalink
ac14ca3c3f
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
39 lines (33 sloc) 1.04 KB
#include <iostream>
using namespace std;
int main()
{
string input; //input string so user can initiate simulation.
int i = 3;
cout << "health: " << i << endl; //prints out the health of user.
cin >> input;
string Yes = "hit"; //string hit to start fight simulation.
if ( input == Yes) //if statement to simulate the fighting changing i to j then to h to keep tally of how much health has been lost or kept.
{
cout << "health: " << i-1 << endl;
}
int j=i-1;
cin >> input;
if (input == Yes)
{
cout << "health: " << j-1 << endl;
}
int h=i-1;
cin >> input;
if (input == Yes)
{
cout << "health: " << h-1 << endl;
}
if (i==0) //if statement when i is equal to 0 so that it will tell the user they have died and see if they want to restart.
{
cout << "Game Over" << endl << "You have Died" << endl;
cout << "would you like to play again? " << endl;
string okay = "yes";
cin >> input;
}
}