diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2020-09-21 15:43:38 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2020-09-21 15:43:38 +0200 |
| commit | e483926bf15d6a560885c9b26d1c51a796583745 (patch) | |
| tree | 64d6c5ea8956667e726462bc8262c84a8274c874 /labb3/tsp/src/Node.cpp | |
| parent | d3e70eb68019f7d4e866dbda6ee8463ec5ad901b (diff) | |
| download | tddd86-e483926bf15d6a560885c9b26d1c51a796583745.tar.gz | |
Given files L3 tsp
Diffstat (limited to 'labb3/tsp/src/Node.cpp')
| -rw-r--r-- | labb3/tsp/src/Node.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/labb3/tsp/src/Node.cpp b/labb3/tsp/src/Node.cpp new file mode 100644 index 0000000..3b7697b --- /dev/null +++ b/labb3/tsp/src/Node.cpp @@ -0,0 +1,32 @@ +/* + * TDDD86 TSP + * This file contains the implementation of the Node structure. + * See Node.h for comments about each member. + * Your code should work properly with an unmodified version of this file. + */ + +#include <iomanip> +#include <iostream> +#include <sstream> +#include "Node.h" + +Node::Node(Point p, Node* _next) + : point(p.x, p.y), next(_next) {} + +string Node::toString() const { + stringstream out; + out << "Node{addr=" << ((void*) this); + out << ", point=" << point; + if (next != nullptr) { + out << ", next=" << ((void*) next); + } else { + out << ", next=nullptr"; + } + out << "}"; + return out.str(); +} + +ostream& operator <<(ostream& out, const Node& node) { + out << node.toString(); + return out; +} |
