I am making a little single-player game and to help with scoring I have created a Player class. Can you review my implementation?
I know that for a multiplayer game this isn't good. For multiplayer I would need to call functions and have all players in one instance.
###File player.h
namespace SDLGamecore { namespace player { class Player { private: long cash; int workers; std::string name; public: Player(std::string playerName) { name = playerName; cash = 0; workers = 0; } ~Player(){} long getCurrentCash() const; int getWorkers() const; std::string getPlayerName() const; }; }} ###File player.cpp
namespace SDLGamecore { namespace player { long Player::getCurrentCash() const { return cash; } int Player::getWorkers() const { return workers; } std::string Player::getPlayerName() const { return name; } }} ###File main.cpp
Player player("Test"); std::string pName = player.getPlayerName(); std::cout << pName << std::endl; The code works as expected. Thank you for any feedback and assistance in improving my single player class.