Question: heroine quest code (C++ code) #include using namespace std; const int SIZE = 10; const string NOT_VALID = INVALID; class creature{ // things! public: creature();
heroine quest code (C++ code) #include
using namespace std; const int SIZE = 10; const string NOT_VALID = "INVALID"; class creature{ // things! public: creature(); creature(string n, int h, int d); string getName(); void attack(creature& other); // for hurting other creatures bool isDead(); // checks to see if you have enoug hp int getHP(); int getDMG(); void setLocation(int r, int c); // sets your location in the world bool move(char dir); // changes location based on "wasd" int getRowLocation(); int getColLocation(); void kill(); // no more creature... private: string name; int hp; int dmg; int worldRow; int worldCol; }; class world{ public: world(); void show(); // displaying the world (and everything on it) char getTile(int r, int c); //shows what is displayed in the world at a row/col creature& getCreature(int r, int c); // returning creature& as I don't want multiple copies of this creature creature& getCreature(string name); // ^^ (probably better to use pointers, but this homework isn't about them) void addCreature(creature &c);// keep track of another creature void processTile(); // figuring out the hero should do at a tile of the map private: void setRow(int r, string s); // used to help initialize map creature list[SIZE*SIZE+1]; // last creature is invalid int creatureCount; // how many creatures are in the list char map[SIZE][SIZE]; }; void clearScreen(); void processTile(world& w); void gotoTown(creature& you); void round(creature& attacker, creature& getHit); bool isFirstLetter(string s, string tests); int main() { string hname; // your name! (or something cool) do { cout 0) // if they didn't just hit enter { // process your movement, then interact with that tile island.getCreature(hname).move(dir[0]); island.processTile(); } } cout = 0; i--) // going backwards so hero is on top of other creatures { if(list[i].getRowLocation() >= 0 && list[i].getRowLocation() = 0 && list[i].getColLocation() = 0; i--) // since heroine is always list[0], we want to check this last so we can tell if heroine is ontop of something else { if(list[i].getRowLocation() == r && list[i].getColLocation() == c && !list[i].isDead()) // only return alive creatures { return list[i]; } } return list[SIZE*SIZE]; // if we don't find anything, return a default creature } creature& world::getCreature(string name) { for(int i=creatureCount-1; i >= 0; i--) // since heroine is always list[0], we want to check this last so we can tell if heroine is ontop of something else { if(list[i].getName() == name && !list[i].isDead()) { return list[i]; } } return list[SIZE*SIZE]; // if we don't find anything, return a default creature } void world::addCreature(creature &c) { list[creatureCount] = c; // list is partiallyed filled array creatureCount++; } void world::processTile() { // find which tile the heroine is on int pRow = list[0].getRowLocation(); int pCol = list[0].getColLocation(); if(map[pRow][pCol] == '~') // if they on the ocean { cout
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock

heroine quest code (C++ code) #include