C++ creating a forest -


am new c++ , trying create burning forest simulator. have been trying call function forest class dont know how give argument, if great here code have @ moment.

using namespace std;    class forestsetup { private:      const char tree = '^';     const char fire = '*';     const char emptyspace = '.';     const char forestborder = '#';     const int firex = 10;     const int firey = 10;      char forest[21][21];   public:      void createforest()     {         // function create forest          (int = 0; < 21; i++) // sets value of rows 0 20         {             (int j = 0; j < 21; j++) // sets value of columns 0 20             {                  if (i == 0 || == 20)                 {                     forest[i][j] = forestborder; // creates north , south of forest border                 }                  else if (j == 0 || j == 20)                 {                     forest[i][j] = forestborder; // creates east , west forest border                 }                  else                 {                     forest[i][j] = tree; // filles rest of arrays trees                 }              }         }          forest[firex][firey] = fire; // sets fire in middle of grid     }      void showforest(char grid[21][21])     {         (int = 0; < 21; i++)         {             (int j = 0; j < 21; j++)             {                 cout << grid[i][j];             }              cout << endl;         }     }    };  int main(void) {       forestsetup myforest;      myforest.showforest();      system("pause");     return 0; } 

let's have setonfire function x , y co-ordinates of want start fire.

public:   setonfire(int x, int y)   {       // code flag part of forest on fire   } 

in main, call

myforest.setonfire(5,5); 

within forestsetup class need setonfire(5,5);

this tutorials point article might help.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -