Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Comando in c++.

Visualizzazione discussione

  1. #4
    Utente di HTML.it
    Registrato dal
    Dec 2013
    Messaggi
    16
    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;
    }
    Ultima modifica di MItaly; 06-04-2014 a 22:19

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.