Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(C++) Only write with C++program please!! **please do not use any pointer and follow the instruction carefully please. source code --------------------------------------------------------------------------- #include using namespace std;
(C++)
Only write with C++program please!!
**please do not use any pointer and follow the instruction carefully please.
source code
---------------------------------------------------------------------------
#includeusing 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 All of these problems relate to "HeroineQuestV2.cpp". This is a rather large piece of code, so you should try to familiarize yourself with it before attempting to solve the problems. You do not need to understand every part of the code to solve the problems, just the general structure of the code. (Note: the left-hand side of geany (under "Symbols") lists the functions (and variables), which can allow you to jump around to them in the code quickly.) When running the program, first you enter a name for the heroine: Who art thou? (Don't start with R' oror') immy Jones Name All of these problems relate to "HeroineQuestV2.cpp". This is a rather large piece of code, so you should try to familiarize yourself with it before attempting to solve the problems. You do not need to understand every part of the code to solve the problems, just the general structure of the code. (Note: the left-hand side of geany (under "Symbols") lists the functions (and variables), which can allow you to jump around to them in the code quickly.) When running the program, first you enter a name for the heroine: Who art thou? (Don't start with R' oror') immy Jones Name
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started