diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2020-08-17 19:34:09 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2020-08-17 19:34:09 +0200 |
| commit | 403ce5391e0fecc51bf50c86070ebc0e6d7e05af (patch) | |
| tree | 248c47b8687baa820d4803784c15a2a6d43405c4 /labb3/tsp/src/Node.cpp | |
| parent | c0a7e9ae20f29bb5d344cbb3923e0967034cadf1 (diff) | |
| download | tddd86-L3.tar.gz | |
add tsp codeL3
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; +} |
