Skip to content
Permalink
Browse files
Create Room.h
  • Loading branch information
bempaha committed Mar 20, 2020
1 parent 869f6c2 commit accbf78b0197af922fe3276f2e370c1c27239b32
Showing 1 changed file with 112 additions and 0 deletions.
112 Room.h
@@ -0,0 +1,112 @@
//code adapted from: https://www.youtube.com/watch?v=ajL1KjTch2A&t=7s and https://www.youtube.com/watch?v=ikA4yiurkug
#ifndef ROOM_H
#define ROOM_H

#include<iostream>
#include<string>

using namespace std;

enum Direction { NORTH = 0, SOUTH = 1, EAST = 2, WEST = 3};

string GetPositionString(Direction direction) {

if (direction == NORTH) { return "NORTH"; }
else if (direction == SOUTH) { return "SOUTH"; }
else if (direction == EAST) { return "EAST"; }
else if (direction == WEST) { return "WEST"; }
else { return "UNKNOWN"; }
}


struct Room {

Room();
Room(string r_name, string r_description);
void CloseRooms(string toNorthRoom, string toEastRoom, string toSouthRoom, string toWestRoom);
void Begin(string id = "", string name = "", string description = "");

void OutputRinfo();
void OutputCloseRooms();
bool CanMoveto(Direction direction);
string GetCloseRoomId(Direction direction);
string GetID();

string id;
string name;
string description;
string closeroomIds[4];


};

Room::Room() {

Begin();

};

Room::Room(string id, string name, string description) {

Begin(id, name, description);

};

void Room::Begin(string id /*= ""*/, string name/*= ""*/, string description/*= ""*/) {

this->id = id;
this->name = name;
this->description = description;

for (int i = 0; i < 4; i++)
{
closeroomIds[i] = "NULL";
}

};

void Room::CloseRooms(string toNorthRoom, string toEastRoom, string toSouthRoom, string toWestRoom) {

closeroomIds[NORTH] = toNorthRoom;
closeroomIds[SOUTH] = toSouthRoom;
closeroomIds[EAST] = toEastRoom;
closeroomIds[WEST] = toWestRoom;

};

void Room::OutputRinfo() {

string userInput;

cout<< "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<< name << endl
<< description << endl
<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
<< endl;

OutputCloseRooms();
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;

cout << "What will you do?" << endl;
cout << "=>";

getline(cin, userInput);
}

void Room::OutputCloseRooms() {

cout << "\t You can go: ";

for (int i = 0; i < 4; i++)
{
if (closeroomIds[i] != "NULL")
{
cout << GetPositionString(Direction(i)) << " ";
}
}

cout << endl;
}


#endif

0 comments on commit accbf78

Please sign in to comment.