Handling Data

Hi!

Im trying to write a (very (very (very))) basic console adventure, and I have run into a bit of a problem. I've come to realize that I dont know how to handle after-compile data! Any help, including pointing me to a tutorial of some kind or anything like that, would be much appreciated.

As its shown below in the .cpp file, im trying to make a new data container based off the room_dimentions type, then compact the x and y of the "room" and add it to the list.

I hope I have been clear!

newbies fo life yo'
word.

support_classes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  #include "support_classes.h"

room_dimensions::room_dimensions (int inX, int inY) // Constructor to call when x and y values are present
     {
			x = inX;
	        y = inY;
     }

object_id::object_id() // Default constructor - Called if nothing else can be
	{	
	}

object_id::object_id(OBJECT_TYPE intype/*type of object asked for*/) // Primary constructor - called when requested with a defining value from the enum
	{
		type_of_object = intype; // Assigns type_of_object the value sent to the class when it was called
		switch (type_of_object)
			case OT_TOOL:
				tool.tool(true);
	}

tool::tool() : object_id(OT_TOOL) // Default constructor called by OBJECT_ID with a value of OT_TOOL
	{
		// ERROR CODE
	}
	tool::tool(bool use) : object_id(OT_TOOL) // Constructor called if there has been a command to use the tool
	{
		if (use == true) in_use = true; // if constructor has been called with use being true, set in_use to true
		if (use == false) in_use = false; // if constructor has been called with use being false, set in_use to false
	}

room::room() : object_id(OT_ROOM) // Default constructor, called if room class is called with out input
	{
		// ERROR CODE
	}
	room::room(bool enter) : object_id(OT_ROOM) // constructor to call is a boolean value is present, indicating in the room or not
	{
		if (enter == true) in_room = true; // if the boolean value is true, assign it true
		if (enter == false) in_room = false; // if the boolean value is false, assign it false

	}
	room::room(int size_x, int size_y) : object_id(OT_ROOM) // constructor to call if two integers are present, aka the size of the room
	{
		/*????????*/ <class room_dimensions> room_grid; // Create a new grid based off room_dimensions, called room_grid
		int increment_x = 0; // incremental integers
		int increment_y = 0;
		if (increment_x == 0, increment_x == size_x, increment_x++) // if the count is at the start, continue untill its at the defined size
		{
			if (increment_y == 0, increment_y == size_y, increment_y++)
			{
				room_dimensions *new_room = NULL; // make a pointer out of room_dimensions, initialise to null
				if ((new_room = new room_dimensions(increment_x, increment_y)) != 0) // as long as the created pointer doesn't come up empty, point new_room to it
						room_grid.     /*???????*/     (new_room); // put X and Y at the end of the room_grid list
				if (increment_y > size_y) { increment_y = 0; } // if y is bigger then the limit, set it to 0
			}
		}

	}


support_classes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "conadv_def.h"


class room_dimensions { // Data type to use as a vector data type when making a grid
public:
	int x;
	int y;
	 room_dimensions(); // Default Constructor
     room_dimensions(int inX, int inY);
	 ~room_dimensions(); // removes room_dimensions from memory
private:
	int x, y; // length and width of the room
};

class object_id // Class to call when using an object from OBJECT_TYPE
{
public: // Seen and used by any outside source
	object_id(); // Default constructor - Called if nothing else can be
	object_id(OBJECT_TYPE intype/*type of object asked for*/); // Primary constructor - called when requested with a defining value from the enum
	~object_id(); // Destroys the object
private: // seen only by the class itself
	OBJECT_TYPE type_of_object; // Declares an enum value called type_of_object
};

class tool : public object_id // A class that interacts with the OBJECT_ID class as its parent
{
public: // Seen and used by any outside source
	tool() : object_id(OT_TOOL); // Default constructor called by OBJECT_ID with a value of OT_TOOL
	tool(bool use) : object_id(OT_TOOL); // Constructor called if there has been a command to use the tool
	~tool();
private: // seen by only the class itself	
	bool in_use; // Is the tool being used
};

class room : public object_id // Class for a room, sub-class of object_id
{
public: // seen by any other class
	room() : object_id(OT_ROOM); // Default constructor, called if room class is called with out input
	room(bool enter) : object_id(OT_ROOM); // constructor to call is a boolean value is present, indicating in the room or not
	room(int size_x, int size_y) : object_id(OT_ROOM); // constructor to call if two integers are present, aka the size of the room
	~room();
private:
	bool in_room; // private data indicating if the player is in the room or not
//	vector<vector<int>> room_size; // multidimensional vector of room size, length and width
};


conadv_def.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Global Definitions
// An enumeration of each type of object in the game
#include <iostream>
#include <vector>
using namespace std;

enum OBJECT_TYPE // Creation of a data type
{
	// Individual data types
	OT_ROOM,
	OT_TOOL,
	OT_PUZZLE,
	OT_NOUN,
	OT_VERB,
	OT_MAX_OBJECT_TYPE
};

enum ROOM_DIVISION_ID
{
	RD_NORTH_WEST,
	RD_NORTH,
	RD_NORTH_EAST,
	RD_EAST,
	RD_SOUTH_EAST,
	RD_SOUTH,
	RD_SOUTH_WEST,
	RD_WEST,
	RD_CENTER,
	RD_MAX_ROOM_DIVISION
};
"After compile time data" in my mind refers to getting input of some sort (user or file). This site has a good tutorial on that.
my question is more about the handling of the input, from 43 - 58 of the .cpp file. Im trying to manipulate a data type, of my own specification, to save the dimentions of the room. later on the goal is to have those dimentions, aka 1x1 or 2x3, be able to interact with each other via a character...

 
/*????????*/ <class room_dimensions> room_grid; // Create a new grid based off room_dimensions, called room_grid 


 
room_grid.     /*???????*/     (new_room); // put X and Y at the end of the room_grid list 
Topic archived. No new replies allowed.