- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/Documents and Settings/jegan/Desktop/projectX/TurnCommand.cpp

Go to the documentation of this file.

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