@@ -18,10 +18,10 @@ ChatLogic::ChatLogic()
18
18
// //
19
19
20
20
// create instance of chatbot
21
- _chatBot = new ChatBot (" ../images/chatbot.png" );
21
+ // _chatBot = new ChatBot("../images/chatbot.png");
22
22
23
23
// add pointer to chatlogic so that chatbot answers can be passed on to the GUI
24
- _chatBot->SetChatLogicHandle (this );
24
+ // _chatBot->SetChatLogicHandle(this);
25
25
26
26
// //
27
27
// // EOF STUDENT CODE
@@ -33,7 +33,7 @@ ChatLogic::~ChatLogic()
33
33
// //
34
34
35
35
// delete chatbot instance
36
- delete _chatBot;
36
+ // delete _chatBot;
37
37
38
38
// No need to manually delete edges now.
39
39
// The child nodes' unique_ptr<GraphEdge> will handle that.
@@ -195,26 +195,28 @@ void ChatLogic::LoadAnswerGraphFromFile(std::string filename)
195
195
196
196
// identify root node
197
197
GraphNode *rootNode = nullptr ;
198
- for (auto &node : _nodes)
198
+ for (auto it = std::begin (_nodes); it != std::end ( _nodes); ++it )
199
199
{
200
200
// search for nodes which have no incoming edges
201
- if (node ->GetNumberOfParents () == 0 )
201
+ if ((*it) ->GetNumberOfParents () == 0 )
202
202
{
203
203
204
204
if (rootNode == nullptr )
205
205
{
206
- rootNode = node .get (); // assign current node to root
206
+ rootNode = (*it) .get (); // assign current node to root
207
207
}
208
208
else
209
209
{
210
210
std::cout << " ERROR : Multiple root nodes detected" << std::endl;
211
211
}
212
212
}
213
213
}
214
-
214
+ ChatBot chatbot (" ../images/chatbot.png" );
215
+ SetChatbotHandle (&chatbot);
215
216
// add chatbot to graph root node
216
- _chatBot->SetRootNode (rootNode);
217
- rootNode->MoveChatbotHere (_chatBot);
217
+ chatbot.SetChatLogicHandle (this );
218
+ chatbot.SetRootNode (rootNode);
219
+ rootNode->MoveChatbotHere (std::move (chatbot));
218
220
219
221
// //
220
222
// // EOF STUDENT CODE
0 commit comments