-
-
Save codecademydev/29576aae3d82db5f652d809f3f7131c1 to your computer and use it in GitHub Desktop.
Codecademy export
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> | |
int main() | |
{ | |
//VARIABLES | |
int choice1 = 0; | |
int outcome1 = 0; | |
//TITLE | |
std::cout << "===========================\n"; | |
std::cout << " A BOY AND HIS BALL\n"; | |
std::cout << " A Text Adventure\n"; | |
std::cout << "===========================\n"; | |
//BEGINNING | |
std::cout << "In the dusky, factory town of Bellville,\n" << "there lived a boy named Melvin.\n" << "Melvin's favorite toy was a red ball,\n" << "that was given to him by his big sister.\n\n"; | |
std::cout << "One day, Melvin was sitting on his porch,\n" << "holding the red ball.\n" << "What should Melvin do with the ball?\n\n"; | |
//First Choice | |
while(choice1 >= 0 && choice1 >= 3) | |
{ | |
std::cout << "1) Bounce the ball\n" << "2) Throw the ball upwards as hard as he can\n" << "3) Continue to hold the ball\n\n"; | |
std::cin >> choice1; | |
if(choice1 == 1) | |
{ | |
std::cout << "Melvin began bouncing the ball.\n" << "But as he was playing, his friend Tim\n" << "called to him from across the street.\n" << "Shifting his attention to his friend,\n" << "Melvin looked away from the ball and it hit\n" << "the toe of his foot, and went bouncing\n" << "down the porch steps,\n" << "and into the street.\n"; | |
outcome1 = 1; | |
} | |
else if(choice1 == 2) | |
{ | |
std::cout << "Melvin threw the ball high into the air!\n" << "But while he was ready to catch it,\n" << "his aim was a little off and the ball bounced\n" << "off the edge of his roof and went\n" << "sailing into the neighbor's back yard.\n\n"; | |
outcome1 = 2; | |
} | |
else if(choice1 == 3) | |
{ | |
std::cout << "Melvin sat on the porch, holding the ball.\n" << "Suddenly, his sister came storming out\n" << "of the house." << " As the screen door swung open,\n" << "it hit the ball and sent it hurdling\n" << "off the side of the porch.\n\n"; | |
outcome1 = 3; | |
} | |
else | |
{ | |
std::cout << "Select a valid option"; | |
std::cin >> choice1; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment