(Solved) : Include Using Namespace Std Const Int Size 10 Const String Notvalid Invalid Class Creature Q32680554 . . .
#include <iostream>
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 othercreaturesbool isDead(); // checks to see if you have enoug hpint getHP();int getDMG();void setLocation(int r, int c); // sets your location in theworldbool 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 onit)char getTile(int r, int c); //shows what is displayed in theworld at a row/colcreature& getCreature(int r, int c); // returningcreature& as I don’t want multiple copies of thiscreaturecreature& getCreature(string name); // ^^ (probably betterto use pointers, but this homework isn’t about them)void addCreature(creature &c);// keep track of anothercreaturevoid processTile(); // figuring out the hero should do at atile of the mapprivate:void setRow(int r, string s); // used to help initializemapcreature list[SIZE*SIZE+1]; // last creature is invalidint creatureCount; // how many creatures are in the listchar 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 << “Who art thou? (Don’t start with ‘R’ or ‘~’ or’.’)n”;getline(cin,hname);}while(hname.length() == 0 || isFirstLetter(hname,”r~.”));
creature heroine = creature(hname, 10, 1);heroine.setLocation(6,5);world island;island.addCreature(heroine); // heroine is always firstcreature// make a rabbitcreature rabby = creature(“Rabbit”, 2, 1);rabby.setLocation(8, 3);island.addCreature(rabby); // save rabbit in the world// … and some more rabbitscreature rabby2 = creature(“Rabbit”, 2, 1);rabby2.setLocation(4, 8);island.addCreature(rabby2); // save rabbit in the world
creature rabby3 = creature(“Rabbit”, 2, 1);rabby3.setLocation(5, 8);island.addCreature(rabby3); // save rabbit in the world
creature rabby4 = creature(“Rabbit’s Revenge”, 2, 9);rabby4.setLocation(4, 8);island.addCreature(rabby4); // save rabbit in the world
while(!island.getCreature(hname).isDead()) // keep going untilyou drop{// show where you are:clearScreen();island.show();// show how healthy you are:cout << “HP: ” <<island.getCreature(hname).getHP() << endl;// ask what you want to do:cout << “Which direction do you want to move (‘w’=up,’a’=left, ‘s’=down, ‘d’=right)? “;string dir;getline(cin, dir);if(dir.length()>0) // if they didn’t just hit enter{// process your movement, then interact with that tileisland.getCreature(hname).move(dir[0]);island.processTile();}}cout << “Game over…n”;}
// hack solutionvoid clearScreen(){cout <<“nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn”;}
// interacting with townvoid gotoTown(creature& you){clearScreen();cout << ” +” << endl;cout << ” / ” << endl;cout << ” ______ ___________/ o ” << endl;cout << “________ | | | | /^” << endl;cout << “| * * *| |: ::| | | //^\ <<endl;cout << “”| * * | |:: | | [] [] [] []| ((|))”” <<endl;cout << “”|* ** | |: 😐 | [] [] [] | ((|))”” <<endl;cout << “”|_[]___| |_||_| |____________;;_| | “” <<endl;
// not a whole lot to do here…cout << you.getName() << “” walks into town
Expert Answer
Answer to Include Using Namespace Std Const Int Size 10 Const String Notvalid Invalid Class Creature Q32680554 . . .
OR