Permalink
Cannot retrieve contributors at this time
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?
Text-Based-game/Text based - lukes other code/yes.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
39 lines (33 sloc)
1.04 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} | |
} |