-
Notifications
You must be signed in to change notification settings - Fork 678
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37e6c37
commit ae04a37
Showing
6 changed files
with
361 additions
and
161 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
#include "graphedge.h" | ||
#include "graphnode.h" | ||
#ifndef GRAPHNODE_H_ | ||
#define GRAPHNODE_H_ | ||
|
||
#include <vector> | ||
#include <string> | ||
#include "chatbot.h" | ||
#include <memory> | ||
|
||
GraphNode::GraphNode(int id) | ||
{ | ||
_id = id; | ||
} | ||
|
||
GraphNode::~GraphNode() | ||
// forward declarations | ||
class GraphEdge; | ||
|
||
class GraphNode | ||
{ | ||
private: | ||
//// STUDENT CODE | ||
//// | ||
|
||
//delete _chatBot; | ||
// data handles (owned) | ||
std::vector<std::unique_ptr<GraphEdge>> _childEdges; // edges to subsequent nodes | ||
|
||
// data handles (not owned) | ||
std::vector<GraphEdge *> _parentEdges; // edges to preceding nodes | ||
ChatBot _chatBot; | ||
|
||
//// | ||
//// EOF STUDENT CODE | ||
} | ||
|
||
void GraphNode::AddToken(std::string token) | ||
{ | ||
_answers.push_back(token); | ||
} | ||
// proprietary members | ||
int _id; | ||
std::vector<std::string> _answers; | ||
|
||
void GraphNode::AddEdgeToParentNode(GraphEdge *edge) | ||
{ | ||
_parentEdges.push_back(edge); | ||
} | ||
public: | ||
// constructor / destructor | ||
GraphNode(int id); | ||
~GraphNode(); | ||
|
||
void GraphNode::AddEdgeToChildNode(std::unique_ptr<GraphEdge> edge) | ||
{ | ||
_childEdges.push_back(std::move(edge)); | ||
} | ||
// getter / setter | ||
int GetID() { return _id; } | ||
int GetNumberOfChildEdges() { return _childEdges.size(); } | ||
GraphEdge *GetChildEdgeAtIndex(int index); | ||
std::vector<std::string> GetAnswers() { return _answers; } | ||
int GetNumberOfParents() { return _parentEdges.size(); } | ||
|
||
//// STUDENT CODE | ||
//// | ||
void GraphNode::MoveChatbotHere(ChatBot chatbot) | ||
{ | ||
_chatBot = std::move(chatbot); | ||
_chatBot.SetCurrentNode(this); | ||
} | ||
|
||
void GraphNode::MoveChatbotToNewNode(GraphNode *newNode) | ||
{ | ||
newNode->MoveChatbotHere(std::move(_chatBot)); | ||
//_chatBot = nullptr; // invalidate pointer at source | ||
} | ||
//// | ||
//// EOF STUDENT CODE | ||
// proprietary functions | ||
void AddToken(std::string token); // add answers to list | ||
void AddEdgeToParentNode(GraphEdge *edge); | ||
void AddEdgeToChildNode(std::unique_ptr<GraphEdge> edge); | ||
|
||
GraphEdge *GraphNode::GetChildEdgeAtIndex(int index) | ||
{ | ||
//// STUDENT CODE | ||
//// | ||
|
||
return _childEdges[index].get(); | ||
void MoveChatbotHere(ChatBot chatbot); | ||
|
||
//// | ||
//// EOF STUDENT CODE | ||
} | ||
|
||
void MoveChatbotToNewNode(GraphNode *newNode); | ||
}; | ||
|
||
#endif /* GRAPHNODE_H_ */ |
Oops, something went wrong.