Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ programming (need full code based on HeroineV2.cpp and should complete the code(missing part as well) using HeroineV2.cpp ) HeroineV2.cpp #include using namespace std; const

C++ programming (need full code based on HeroineV2.cpp and should complete the code(missing part as well) using HeroineV2.cpp )

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

image text in transcribed

HeroineV2.cpp

#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 && 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   Instructions: This is an individual homework assignment. There are two problems worth 20 points each. Solve the problem below by yourself (unlike the labs, where you work collaboratively), and submit the solution as a C++source code file. Here are a few more important details: 1. Unlike the computer lab exercises, this is not a collaborative assignment. 2. Because all homework assignments are submitted and tested electronically, the fol- lowing are important You follow any naming conventions mentioned in the homework instructions. You submit the correct file(s) through Moodle by the due deadline You follow the example input and output formats exactly given in each problem description Regardless of how or where you develop your solutions, your programs compile and execute on cselabs computers running the Linux operating system. 3. You should test your program on other test cases (that you make up) as well. Making up good test cases is a valuable programming skill, and is part of ensuring your code solution is correct. All of these problems relate to "HeroineQuest V2.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 Then you are shown to a map. You move using "wasd" (type one then press enter)  Instructions: This is an individual homework assignment. There are two problems worth 20 points each. Solve the problem below by yourself (unlike the labs, where you work collaboratively), and submit the solution as a C++source code file. Here are a few more important details: 1. Unlike the computer lab exercises, this is not a collaborative assignment. 2. Because all homework assignments are submitted and tested electronically, the fol- lowing are important You follow any naming conventions mentioned in the homework instructions. You submit the correct file(s) through Moodle by the due deadline You follow the example input and output formats exactly given in each problem description Regardless of how or where you develop your solutions, your programs compile and execute on cselabs computers running the Linux operating system. 3. You should test your program on other test cases (that you make up) as well. Making up good test cases is a valuable programming skill, and is part of ensuring your code solution is correct. All of these problems relate to "HeroineQuest V2.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 Then you are shown to a map. You move using "wasd" (type one then press enter)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

Write an elaborate note on marketing environment.

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago