00001 #include "Command.h" 00002 #include "Control.h" 00003 #include "List.h" 00004 #include "Level.h" 00005 #include "Person.h" 00006 00007 using namespace std; 00008 00009 const std::string KillCommand::_id = "kill"; 00010 00011 KillCommand::KillCommand(Person *person) 00012 :_person(person->id()) 00013 { 00014 00015 } 00016 00017 KillCommand::KillCommand(List *command) 00018 { 00019 command = command->rest(); 00020 _person = command->firstString(); 00021 } 00022 00023 void KillCommand::execute() 00024 { 00025 ((Person *)Level::instance()->getObject(_person))->die(); 00026 } 00027 00028 std::string KillCommand::getString() 00029 { 00030 List *command = new List(); 00031 command->snoc(new Atom(_id)); 00032 command->snoc(new Atom(_person)); 00033 string commandString = command->getString(); 00034 delete command; 00035 00036 return commandString; 00037 }
1.4.6-NO