- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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

Go to the documentation of this file.

    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         PlaySoundCommand("sounds/nicechime.wav").execute();
    00026 }
    00027
    00028 std::string AddScoreCommand::getString()
    00029 {
    00030         List *command = new List();
    00031         command->snoc(new Atom(_id));
    00032         stringstream score;
    00033         score << _score;
    00034         command->snoc(new Atom(score.str()));
    00035         string commandString = command->getString();
    00036         delete command;
    00037
    00038         return commandString;
    00039 }