Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 30, 2017, 9:33:27 AM (6 years ago)
Author:
kuchlert
Message:

fixed addQuestion and addAnswer in Dialog

File:
1 edited

Legend:

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

    r11607 r11611  
    55#include "Dialog.h"
    66#include "Question.h"
     7
    78
    89namespace orxonox
     
    5758        void Dialog::addQuestion(Question* question) //fuegt Question der Map hinzu
    5859        {
    59                 //questions_.emplace(question->getQuestionId(), question->getQuestion());
     60                this->questions_.insert(make_pair(question->getQuestionId(), question));
    6061        }
    6162
    6263        void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu
    6364        {
    64                 //answers_.emplace(std::make_pair(answer->getAnswerId(), answer->getAnswer()));
     65                this->answers_.insert(make_pair(answer->getAnswerId(), answer));
    6566        }
    6667
     
    7273        }
    7374
    74         Answer* Dialog::getAnswer(unsigned int index) const//tolua_export               //returned sting der Antwort zur Id.
     75        Answer* Dialog::getAnswer(unsigned int index) const     //returned sting der Antwort zur Id.
    7576        {
    7677                return nullptr;
     
    8182        {
    8283
    83                 Question question = (questions_.find(this->currentQuestionId_))->second;
    84                 std::vector<std::string> answers = question.getAnswerIds();
     84                Question* question = (this->questions_.find(this->currentQuestionId_))->second;
     85                std::vector<std::string> answers = question->getAnswerIds();
    8586                return answers;
    8687        }
     
    9899    void Dialog::update(std::string givenAnswer)
    99100    {
    100         Answer answer = (answers_.find(givenAnswer))->second;
    101         this->currentQuestionId_ = answer.getNextQuestion();
     101        Answer* answer = (answers_.find(givenAnswer))->second;
     102        this->currentQuestionId_ = answer->getNextQuestion();
    102103    }
    103104
    104     bool Dialog::ending() //tolua_export        //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
     105    bool Dialog::ending() //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
    105106    {
    106107        bool end = false;
    107108        if (this->currentQuestionId_ == "end"){
    108109                end = true;
    109         } else if ((questions_.find(this->currentQuestionId_)->second).getAnswerIds().empty()){
     110        } else if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds().empty()){
    110111                end = true;
    111112        }       
Note: See TracChangeset for help on using the changeset viewer.