ci sono stati dati questi file
codice:
#ifndef COMMAND_H_INCLUDED
#define COMMAND_H_INCLUDED
#include <string>
#include <vector>
class Game;
class Command
{
private:
//--------------------------------------------------------------------------
// Private copy constructor
Command(const Command& original);
//--------------------------------------------------------------------------
// Private assignment operator
Command& operator=(const Command& original);
//--------------------------------------------------------------------------
/// Name of this command
std::string command_name_;
public:
//--------------------------------------------------------------------------
// Consturctor
Command(std::string name);
//--------------------------------------------------------------------------
// Destructor
virtual ~Command();
//--------------------------------------------------------------------------
// Executes the command.
// @param board The board where action should be performed on
// @param params Possible parameters neede for the execution
// @return Integer representing the success of the action
virtual int execute(Game& board, std::vector<std::string>& params) = 0;
//--------------------------------------------------------------------------
// Getter Methods
const std::string& getName() const;
};
#endif //COMMAND_H_INCLUDED
poi questo
codice:
#include "Command.h"
//------------------------------------------------------------------------------
Command::Command(std::string name) : command_name_(name)
{
}
//------------------------------------------------------------------------------
Command::~Command()
{
}
//------------------------------------------------------------------------------
const std::string &Command::getName() const
{
return command_name_;
}
e questo
codice:
#include "Game.h"
#include "Monster.h"
#include "Tower.h"
#include "SpeedRatio.h"
//------------------------------------------------------------------------------
int main()
{
Game game( 1000, 20, 5, 3 );
game.addTower( new Tower("Arrow", 1, 3, SpeedRatio(1, 1), &game ) );
game.addTower( new Tower("Cannon", 3, 3, SpeedRatio(1, 3), &game ) );
game.addMonster( new Monster("Slime", 1, 1, 0, SpeedRatio(1, 2), &game ) );
game.addMonster( new Monster("Rat", 1, 2, 0, SpeedRatio(1, 1), &game ) );
game.run();
return 0;
}