Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 8, 2017, 2:55:15 PM (6 years ago)
Author:
kuchlert
Message:

eigentlich fertig nur noch altes system entfernen

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc

    r11642 r11644  
    3535    }
    3636
    37         void Dialog::setName(std::string name)
     37        void Dialog::setName(const std::string& name)
    3838        {
    3939                this->name_ = name;
    4040        }
    4141
    42         std::string Dialog::getName()
     42        const std::string& Dialog::getName() const
    4343        {
    4444                return this->name_;
    4545        }
    4646
    47         void Dialog::setCurrentQuestionId(std::string questionId)
     47        void Dialog::setCurrentQuestionId(const std::string& questionId)
    4848        {
    4949                this->currentQuestionId_ = questionId;
    5050        }
    5151
    52         std::string Dialog::getCurrentQuestionId()
     52        const std::string& Dialog::getCurrentQuestionId() const
    5353        {
    5454                return this->currentQuestionId_;
     
    6161        }
    6262
     63        const Question* Dialog::getQuestion() const // returned nichts
     64        {
     65                return nullptr;
     66        }
     67
    6368        void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu
    6469        {
     
    6671        }
    6772
    68         Question* Dialog::getQuestion(unsigned int index) const // returned nichts
     73        const Answer* Dialog::getAnswer(unsigned int index) const       //returned sting der Antwort zur Id.
    6974        {
    7075                return nullptr;
    71                 // Question question = (questions_.find(this->currentQuestionId_))->second;
    72                 // return question.getQuestion();
    7376        }
    7477
    75         Answer* Dialog::getAnswer(unsigned int index) const     //returned sting der Antwort zur Id.
    76         {
    77                 return nullptr;
    78                 // return (this->answers_.find(answerId))->second.getAnswer();
    79         }
    8078
    81         std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds
     79        const std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds
    8280        {
    8381               
    8482                Question* question = (this->questions_.find(this->currentQuestionId_))->second;
    85                 std::vector<std::string>* answers = question->getAnswerIds();
     83                const std::vector<std::string>* answers = question->getAnswerIds();
    8684                return answers;
    8785               
     
    103101    }
    104102
    105     void Dialog::update(std::string givenAnswer)
     103    void Dialog::update(const std::string& givenAnswerId)
    106104    {
    107         Answer* answer = (answers_.find(givenAnswer))->second;
     105        Answer* answer = (answers_.find(givenAnswerId))->second;
    108106        this->currentQuestionId_ = answer->getNextQuestion();
    109107    }
    110108
    111     bool Dialog::ending() //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
     109    bool Dialog::ending(const std::string& givenAnswerId)
    112110    {
    113         bool end = false;
    114         if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds()->empty()){
    115                 end = true;
    116         }       
    117         return end;
     111        return !this->questions_.count(this->answers_.find(givenAnswerId)->second->getNextQuestion());
    118112    }
    119113
    120         std::string Dialog::getQuestionString()
     114        const std::string& Dialog::getQuestionString()
    121115        {
    122116                return this->questions_.find(this->currentQuestionId_)->second->getQuestion();
    123117        }
    124118
    125         std::string Dialog::getAnswerString(std::string answerId)
     119        const std::string& Dialog::getAnswerString(std::string answerId)
    126120        {
    127121                return this->answers_.find(answerId)->second->getAnswer();
Note: See TracChangeset for help on using the changeset viewer.