Changeset 11644 for code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc
- Timestamp:
- Dec 8, 2017, 2:55:15 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc
r11642 r11644 35 35 } 36 36 37 void Dialog::setName( std::stringname)37 void Dialog::setName(const std::string& name) 38 38 { 39 39 this->name_ = name; 40 40 } 41 41 42 std::string Dialog::getName()42 const std::string& Dialog::getName() const 43 43 { 44 44 return this->name_; 45 45 } 46 46 47 void Dialog::setCurrentQuestionId( std::stringquestionId)47 void Dialog::setCurrentQuestionId(const std::string& questionId) 48 48 { 49 49 this->currentQuestionId_ = questionId; 50 50 } 51 51 52 std::string Dialog::getCurrentQuestionId()52 const std::string& Dialog::getCurrentQuestionId() const 53 53 { 54 54 return this->currentQuestionId_; … … 61 61 } 62 62 63 const Question* Dialog::getQuestion() const // returned nichts 64 { 65 return nullptr; 66 } 67 63 68 void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu 64 69 { … … 66 71 } 67 72 68 Question* Dialog::getQuestion(unsigned int index) const // returned nichts73 const Answer* Dialog::getAnswer(unsigned int index) const //returned sting der Antwort zur Id. 69 74 { 70 75 return nullptr; 71 // Question question = (questions_.find(this->currentQuestionId_))->second;72 // return question.getQuestion();73 76 } 74 77 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 }80 78 81 std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds79 const std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds 82 80 { 83 81 84 82 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(); 86 84 return answers; 87 85 … … 103 101 } 104 102 105 void Dialog::update( std::string givenAnswer)103 void Dialog::update(const std::string& givenAnswerId) 106 104 { 107 Answer* answer = (answers_.find(givenAnswer ))->second;105 Answer* answer = (answers_.find(givenAnswerId))->second; 108 106 this->currentQuestionId_ = answer->getNextQuestion(); 109 107 } 110 108 111 bool Dialog::ending( ) //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind109 bool Dialog::ending(const std::string& givenAnswerId) 112 110 { 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()); 118 112 } 119 113 120 std::stringDialog::getQuestionString()114 const std::string& Dialog::getQuestionString() 121 115 { 122 116 return this->questions_.find(this->currentQuestionId_)->second->getQuestion(); 123 117 } 124 118 125 std::stringDialog::getAnswerString(std::string answerId)119 const std::string& Dialog::getAnswerString(std::string answerId) 126 120 { 127 121 return this->answers_.find(answerId)->second->getAnswer();
Note: See TracChangeset
for help on using the changeset viewer.