]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Add slot border getter/setter
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 16 Jul 2019 08:34:04 +0000 (10:34 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 16 Jul 2019 08:50:23 +0000 (10:50 +0200)
api/pslot.h
ut/pslot.t.cc

index bfd984f715135d024937290021f52fc2255a0d26..65d888725628521a6441aba975c1a474e4b823d2 100644 (file)
@@ -3,11 +3,57 @@
 
 /*! \brief Parking slot basic class.
 
-This class contains some geometrical computations of parking slot.
+This class contains some geometrical computations of parking slot. Parking slot
+consists of 4 cartesian coordinates `border` representing the border of the
+parking slot.
+
+\param border Array of 4 `x`, `y` values - the borderd of the parking slot.
 */
 class ParkingSlot {
         private:
+                double border_[4][2] = {
+                        {0, 0},
+                        {1, 0},
+                        {1, 2},
+                        {0, 2}
+                };
         public:
+                // getters, setters
+                double x1() const { return this->border_[0][0]; }
+                double y1() const { return this->border_[0][1]; }
+                double x2() const { return this->border_[1][0]; }
+                double y2() const { return this->border_[1][1]; }
+                double x3() const { return this->border_[2][0]; }
+                double y3() const { return this->border_[2][1]; }
+                double x4() const { return this->border_[3][0]; }
+                double y4() const { return this->border_[3][1]; }
+                /*! \brief Set parking slot border.
+
+                \param x1 First `x` coordinate.
+                \param y1 First `y` coordinate.
+                \param x2 Second `x` coordinate.
+                \param y2 Second `y` coordinate.
+                \param x3 Third `x` coordinate.
+                \param y3 Third `y` coordinate.
+                \param x4 The last (fourth) `x` coordinate.
+                \param y4 The last (fourth) `y` coordinate.
+                */
+                void border(
+                        double x1, double y1,
+                        double x2, double y2,
+                        double x3, double y3,
+                        double x4, double y4
+                ) {
+                        this->border_[0][0] = x1;
+                        this->border_[0][1] = y1;
+                        this->border_[1][0] = x2;
+                        this->border_[1][1] = y2;
+                        this->border_[2][0] = x3;
+                        this->border_[2][1] = y3;
+                        this->border_[3][0] = x4;
+                        this->border_[3][1] = y4;
+                };
+
                 ParkingSlot();
 };
 
index 75165fbbbb952c75b7cbd6bfb54811f1829dce5f..be27c92d459480951035706298032128b475c873 100644 (file)
@@ -6,4 +6,5 @@
 WVTEST_MAIN("pslot basic geometry")
 {
         ParkingSlot *ps = new ParkingSlot();
+        ps->border(1, 1, 3, 3, 2, 4, 0, 2);
 }