2d array maps with if statements c++ -


i working on program produces map. in print map function, taking in boolean parameter. if showtreasure true, treasure print out , vice versa. have print characters out on map though. t treasure @ end, s start throughout whole program, x place player has visited, , p player is. if none of apply, prints star. figured out how treasure , star, can't seem other 3 work. here have:

// cell types - map can have of these // characters @ location on map. const char start = 's'; const char player = 'p'; const char treasure = 't'; const char empty = '*'; const char visited = 'x'; 

print map function:

// name: printmap // description: prints map shown in example //      program output on assignment page. // return: nothing // --------------------------------------------------- void printmap(const char map[][cols], const bool showtreasure, int &treasurer, int      &treasurec,           int &startr, int &startc, int &row, int &col) {      (int row = 0; row < rows; row++)     {        (int col = 0; col < cols; col++)        {             if ((row == treasurer && col == treasurec) && showtreasure == true)                cout << treasure;            else if ((row == startr && col == startc) && showtreasure == true)                cout << start;            else                cout << empty;        }      cout <<  endl;     }   } 

moin,

just wondering why passed const char map[][cols]but didn't use it. print value of map[row][col] under condition showtreasure true. won't need int& parameters.

greez alnjeno


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -