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 59 60 61 62
|
#ifndef parse_h
#define parse_h
#include <string>
//Class definition for Parser Class
class Parser
{
//class 2d array to store dictionary of commands
char * commands [50];
//char 2d array to store dicitionary of oobjects
char* objects[50];
//number of commands
int numcommands;
//number of objects
int numobjects;
public:
//default constructor
Parser()
{
numcommands = 12;
numobjects = 12;
//a word to do something
char* cmds[] = {"north", "east", "south",
"west", "pick", "open",
"read", "drop", "eat",
"close", "look", "search"};
//an object that can be used to intract with object.
char* objs[] = {"fork", "knife", "sword",
"enemy", "monster", "shield",
"armour", "spoon", "table",
"door", "room", "key"};
//initialise commands array with these valid command words
for(int i=0 ; i<numcommands ; i++)
{
commands[i] = cmds[i];
}
//initialise objects array with these valid object words
for(int i=0 ; i<numobjects ; i++)
{
objects[i] = objs[i];
}
}
//return a char array which is lowercase version of input char array
char* LowerCase (char* st);
//This method will remove all instance of "the" from a sentence
// and return a pointer to the new stripped sentence
char* RemoveThe(char* sen);
//This method will return a pointer to a char array with the acition of the input
//sentence after it has been parsed of articles
char* GetVerb(char* sen);
//This method will return the object of the input
//sentence after it has been parsed of articles
char* GetObject(char* sen);
void SortCommands();
void SortObjects();
void PrintCommands();
void PrintObjects();
bool IsWordinCommands(char* target);
bool IsWordinObjects(char* target);
};
#endif
|