00001 #include "Command.h" 00002 #include "List.h" 00003 #include "Level.h" 00004 #include <sstream> 00005 00006 using namespace std; 00007 00008 const std::string AddScoreCommand::_id = "addScore"; 00009 00010 AddScoreCommand::AddScoreCommand(int score) 00011 :_score(score) 00012 { 00013 00014 } 00015 00016 AddScoreCommand::AddScoreCommand(List *command) 00017 { 00018 command = command->rest(); 00019 _score = command->firstInt(); 00020 } 00021 00022 void AddScoreCommand::execute() 00023 { 00024 Level::instance()->addScore(_score); 00025 } 00026 00027 std::string AddScoreCommand::getString() 00028 { 00029 List *command = new List(); 00030 command->snoc(new Atom(_id)); 00031 stringstream score; 00032 score << _score; 00033 command->snoc(new Atom(score.str())); 00034 string commandString = command->getString(); 00035 delete command; 00036 00037 return commandString; 00038 }