summaryrefslogtreecommitdiff
path: root/src/point.cpp
diff options
context:
space:
mode:
authorLogan Hunt <loganthebean222@gmail.com>2020-08-12 14:13:50 -0600
committerLogan Hunt <loganthebean222@gmail.com>2020-08-12 14:13:50 -0600
commit70ea8877ace50d2ce609d7d5f721c887b0ea83ec (patch)
tree514aa4f3d10b0a1db21928f8a002aa10458ecbb5 /src/point.cpp
parent495f771530ce1869098bc568f34c243697cab73c (diff)
downloadskeet-cs165-70ea8877ace50d2ce609d7d5f721c887b0ea83ec.tar.gz
skeet-cs165-70ea8877ace50d2ce609d7d5f721c887b0ea83ec.zip
Added files
Diffstat (limited to 'src/point.cpp')
-rw-r--r--src/point.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/point.cpp b/src/point.cpp
new file mode 100644
index 0000000..4008da6
--- /dev/null
+++ b/src/point.cpp
@@ -0,0 +1,58 @@
+
+#include "point.h"
+#include <cassert>
+
+/******************************************
+ * POINT : CONSTRUCTOR WITH X,Y
+ * Initialize the point to the passed position
+ *****************************************/
+Point::Point(float x, float y) : x(0.0), y(0.0)
+{
+ setX(x);
+ setY(y);
+}
+
+/*******************************************
+ * POINT : SET X
+ * Set the x position if the value is within range
+ *******************************************/
+void Point::setX(float x)
+{
+ this->x = x;
+}
+
+/*******************************************
+ * POINT : SET Y
+ * Set the y position if the value is within range
+ *******************************************/
+void Point::setY(float y)
+{
+ this->y = y;
+}
+
+/******************************************
+ * POINT insertion
+ * Display coordinates on the screen
+ *****************************************/
+std::ostream & operator << (std::ostream & out, const Point & pt)
+{
+ out << "(" << pt.getX() << ", " << pt.getY() << ")";
+ return out;
+}
+
+/*******************************************
+ * POINT extraction
+ * Prompt for coordinates
+ ******************************************/
+std::istream & operator >> (std::istream & in, Point & pt)
+{
+ float x;
+ float y;
+ in >> x >> y;
+
+ pt.setX(x);
+ pt.setY(y);
+
+ return in;
+}
+