Code: Select all
#include <iostream>
#include <string>
using namespace std;
// This is where all the rooms are created.
// Further down is a function that connects all the rooms.
class roomcreation{
public:
void setName(string name);
string getName();
void setDesc(string desc);
string getDesc();
private:
string itsName;
string itsDesc;};
void roomcreation::setName(string name){
itsName = name;}
string roomcreation::getName(){
return itsName;}
void roomcreation::setDesc(string desc){
itsDesc = desc;}
string roomcreation::getDesc(){
return itsDesc;}
int main(){
int playerPosition = 0;
string name;
string choice;
roomcreation room1;
room1.setName("Room 1\n");
room1.setDesc("This is a blank room.\n\n");
roomcreation room2;
room2.setName("Room 2\n");
room2.setDesc("This is a blank room.\n\n");
roomcreation room3;
room3.setName("Room 3\n");
room3.setDesc("This is a blank room.\n\n");
cout << "Please enter a name: ";
cin >> name;
cout << "Name has been set to " << name << ".\n\n";
while(choice != "quit"){
if(playerPosition == 0){
cout << room1.getName();
cout << room1.getDesc();
cout << ": ";
cin >> choice;
if(choice == "n"){
playerPosition = 1;}}
if(playerPosition == 1){
cout << room2.getName();
cout << room2.getDesc();
cout << ": ";
cin >> choice;
if(choice == "n"){
playerPosition = 2;}
if(choice == "s"){
playerPosition = 0;}}
if(playerPosition == 2){
cout << room3.getName();
cout << room3.getDesc();
cout << ": ";
cin >> choice;
if(choice == "s"){
playerPosition = 1;}}}
return 0;}
Anyways, enjoy.
-Ghost