summaryrefslogtreecommitdiffstats
path: root/labb3/tsp/src/Point.h
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2020-08-17 19:34:09 +0200
committerGustav Sörnäs <gusso230@student.liu.se>2020-08-17 19:34:09 +0200
commit403ce5391e0fecc51bf50c86070ebc0e6d7e05af (patch)
tree248c47b8687baa820d4803784c15a2a6d43405c4 /labb3/tsp/src/Point.h
parentc0a7e9ae20f29bb5d344cbb3923e0967034cadf1 (diff)
downloadtddd86-403ce5391e0fecc51bf50c86070ebc0e6d7e05af.tar.gz
add tsp codeL3
Diffstat (limited to 'labb3/tsp/src/Point.h')
-rw-r--r--labb3/tsp/src/Point.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/labb3/tsp/src/Point.h b/labb3/tsp/src/Point.h
new file mode 100644
index 0000000..e0d0f31
--- /dev/null
+++ b/labb3/tsp/src/Point.h
@@ -0,0 +1,53 @@
+/*
+ * TDDD86 TSP
+ * This file contains the declaration of the Point structure.
+ * See Point.cpp for implementation of each member.
+ * Your code should work properly with an unmodified version of this file.
+ */
+
+#ifndef POINT_H
+#define POINT_H
+
+#include <iostream>
+#include <string>
+#include <QGraphicsScene>
+using namespace std;
+
+/*
+ * Each Point structure represents a single point in the Euclidean plane.
+ */
+struct Point {
+ const double x; // x position of point
+ const double y; // y position of point
+
+ Point(double _x, double _y);
+
+ /*
+ * Returns Euclidean distance between this point and that.
+ */
+ double distanceTo(Point that) const;
+
+ /*
+ * Draws the point onto the given QGraphicsScene.
+ */
+ void draw(QGraphicsScene* scene) const;
+
+ /*
+ * Draws the line from this point to that onto the given QGraphicsScene.
+ */
+ void drawTo(Point that, QGraphicsScene* scene) const;
+
+ /*
+ * Returns a string representation of the point, such as
+ * (2.5, 3.5).
+ */
+ string toString() const;
+};
+
+/*
+ * Outputs the given point to the given output stream (e.g. cout) in the same
+ * format as returned by its toString member function.
+ */
+ostream& operator<<(ostream& out, const Point& p);
+
+#endif // POINT_H