c++ - Make a BattleShip Board from a txt -
i need huge sorting thing out
here's board , player classes:
class board { public: board(const string &filename); //bool putship(const ship &s); void moveships(); //bool attack(const bomb &b); void display()const; void show()const; void initializegrid(); private: int numlines, numcolumns; //vector <ship> ships; vector <vector<int> > board; }; class player{ public: player(string playername, string boardfilename); void showboard() const; //bomb getbomb() const; //void attackboard(const bomb &b); private: string name; board board; }; this not made me, these classes need implement on final c++ project.
i'm struggling making board (developing function void player::viewboard())
the txt file this
board 10x10 and developed function reads both 10's , saves in numlines , numcolumns:
board::board(const string &filename){ string tmp; ifstream config; config.open(filename.c_str()); if (config.is_open()) { config >> tmp >> numlines >> tmp >> numcolumns; } } but what? how can make board player player dimensions specified on board?
any help? appreciate guys, can save semester. thank , best regards.
well class definition says board vector of vectors of ints
you need make numlines vectors of numcolumns ints , store them in board. (read on std::vector)
i assume each int represents contents of cell. have decide each value means - or did class designer decide that. since cant see other methods dont know
Comments
Post a Comment