From e483926bf15d6a560885c9b26d1c51a796583745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 21 Sep 2020 15:43:38 +0200 Subject: Given files L3 tsp --- labb3/tsp/src/Point.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 labb3/tsp/src/Point.h (limited to 'labb3/tsp/src/Point.h') 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 +#include +#include +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 -- cgit v1.2.1