Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int _playerLife = 100, playerLifeDecrease, i;
- //loop{
- // display the player health
- // ask how much they would like to reduce the health by
- // print out the reduced health
- // if health <= 0 print("Early exit")
- // break out of the loop
- // if the player has looped through 10 times and still health remaining,
- // print("All 10 questions asked, life remaining")
- // Also check if i = 10 AND if there is any life remaining, if not
- // display messaging saying 10 questions asked but no life remaining
- //}
- for (i = 0; i < 10; i++){
- // display health
- cout << "Player HP: " << _playerLife << endl;
- // ask how much to reduce by and print
- cout << "How much should we decrease the player health by?" << endl;
- cin >> playerLifeDecrease;
- _playerLife -= playerLifeDecrease;
- // after 10 loops through check how the remaining life score
- if (i == 9){
- cout << "Player HP: " << _playerLife << endl;
- cout << "All 10 questions have been asked and the player ";
- if (_playerLife > 0){
- cout << "still has life remaining" << endl;
- break;
- }
- else{
- cout << "has no life remaining" << endl;
- break;
- }
- }
- // if health <= 0
- if (_playerLife <= 0){
- cout << "Player HP: " << _playerLife << endl;
- cout << "Early exit" << endl;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement