Interactive story using classes
Code:
#include <iostream>
using namespace std;
class hell
{public:
int number2;
void hot ()
{cout << "you like the fire, huh?\npress 1:yes or 2:no\n";
cin >> number2;
if (number2 == 1)
{ system ("CLS");
cout << "ice prison for you then\n";}
else if (number2 == 2)
{ system ("CLS");
cout << "it gets hotter\n";}
}};
class heaven
{public:
int number3;
void cold ()
{cout << "Blow the mist?\npress 1:yes or 2:no\n";
cin >> number3;
if (number3 == 1)
{ system ("CLS");
cout << "You see paradise all around\n";}
else if (number3 == 2)
{ system ("CLS");
cout << "Well then this is interesting!\n";}
}};
int main()
{
int number;
hell h1;
heaven h2;
cout << "press 1 to go to hell or 2 to go to heaven:\n";
cin >> number;
system ("CLS");
if (number == 1)
h1.hot ();
else if (number == 2)
h2.cold ();
else {cout << "You stay in limbo\n";}
return 0;
}
I have been trying to get my head around classes and why they are helpful. I originaly wrote the whole program in main then changed it.