title: Point2D class objects
body: <p>This is what I need to do: Add a new data member, string color to your Point2D class and a new getter and setter function for color. Create a Point2D object and set its color. Then create a Point3D color and try to set its color. Is this setColor behavior available for a Point3D class? Why or why not?</p>
  
  <p>This is my code: </p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  using namespace std;
  
  class Point2D
  {
      friend class SPALops;
      protected:
          float x;
          float y;
  
      protected:  
          float getX(){
              return x;
          };
          float getY(){
              return y;
          };
          void setX(float xc){
              x = xc;
          };
          void setY(float yc){
              y = yc;
          };
  
          Point2D(int xcoord, int ycoord){
              x = xcoord;
              y = ycoord;
          };
  };
  
  
  class Point2D : Point2D
  {
      friend class SPALops;
          public:
  
          Point2D(int x, int y) : Point2D(x,y){}
  
          Point2D() : Point2D(0,0){}
  
      float getX(){
          return this-&gt;Point2D::getX();
      };
  
      float getY(){
          return this-&gt;Point2D::getY();
      };
  
      void setX(float x){
          this-&gt;Point2D::setX(x);
      };
  
      void setY(float y){
          this-&gt;Point2D::setY(y);
      };
  
  
  
  };
  
  
  class RectangleImplementation{
      friend class SPALops;
      protected:
          Point2D ll;
          Point2D ur;
  
          RectangleImplementation(float llx, float lly, float urx, float ury){
              ll.setX(llx); ll.setY(lly);
              ur.setX(urx); ur.setY(ury);
          }
  
          void setLLx(float x){
              ll.setX(x);
          };
          void setLLy(float y){
              ll.setY(y);
          };
          void setURx(float x){
              ur.setX(x);
          };
          void setURy(float y){
              ur.setY(y);
          };
          float getLLx(){
              return ll.getX();
          };
          float getLLy(){
              return ll.getY();
          };
          float getURx(){
              return ur.getX();
          };
          float getURy(){
              return ur.getY();
          };
  
          vector&lt;vector&lt;float&gt; &gt; getPointList(){
              vector&lt;vector&lt;float&gt; &gt; v(4);
              vector&lt;float&gt; llv(2); llv[0] = ll.getX(); llv[1] = ll.getY();
              v[0] = llv;
              vector&lt;float&gt; luv(2); luv[0] = ll.getX(); luv[1] = ur.getY();
              v[1] = luv;
              vector&lt;float&gt; ruv(2); ruv[0] = ur.getX(); ruv[1] = ur.getY();
              v[2] = ruv;
              vector&lt;float&gt; rlv(2); rlv[0] = ur.getX(); rlv[1] = ll.getY();
              v[3] = rlv;      
              return v;    
          };
  
          void printPointList(){
              vector&lt;vector&lt;float&gt;&gt; v = this-&gt;getPointList();
              cout &lt;&lt; "ll = " &lt;&lt; v[0][0] &lt;&lt; " , " &lt;&lt; v[0][1] &lt;&lt; endl;
              cout &lt;&lt; "lu = " &lt;&lt; v[1][0] &lt;&lt; " , " &lt;&lt; v[1][1] &lt;&lt; endl;
              cout &lt;&lt; "ru = " &lt;&lt; v[2][0] &lt;&lt; " , " &lt;&lt; v[2][1] &lt;&lt; endl;
              cout &lt;&lt; "rl = " &lt;&lt; v[3][0] &lt;&lt; " , " &lt;&lt; v[3][1] &lt;&lt; endl;
          };
  
  };
  
  class Rectangle : RectangleImplementation{
      friend class SPALops;
      public:
  
      Rectangle(Point2D &amp;p, Point2D &amp;q) : RectangleImplementation(p.getX(), p.getY(), q.getX(), q.getY()){};
      Rectangle(float llx, float lly, float urx, float ury): RectangleImplementation(llx,lly,urx,ury){};
  
      float getLLx(){
          return this-&gt;RectangleImplementation::getLLx();
      };
      float getLLy(){
          return this-&gt;RectangleImplementation::getLLy();
      };
      float getURx(){
          return this-&gt;RectangleImplementation::getURx();  
      };
      float getURy(){
          return this-&gt;RectangleImplementation::getURy();
      };
  
      void setLLx(float x){
          this-&gt;RectangleImplementation::setLLx(x);
      };
      void setLLy(float y){
          this-&gt;RectangleImplementation::setLLy(y);
      };
      void setURx(float x){
          this-&gt;RectangleImplementation::setURx(x);
      };
      void setURy(float y){
          this-&gt;RectangleImplementation::setURx(y);
      };
  
      void printPointList(){
          cout &lt;&lt; "In rectangle: " &lt;&lt; endl;
          cout &lt;&lt; "ll = " &lt;&lt; ll.getX() &lt;&lt; " , " &lt;&lt; this-&gt;RectangleImplementation::getLLy() &lt;&lt; endl;
          cout &lt;&lt; "ru = " &lt;&lt; this-&gt;getURx() &lt;&lt; " , " &lt;&lt; this-&gt;RectangleImplementation::getURy() &lt;&lt; endl;
      };
  };
  
  
  class SPALops{
  public:
  static bool touches(Rectangle &amp;r, Point2D &amp;p){
          vector&lt;vector&lt;float&gt; &gt; v = r.RectangleImplementation::getPointList();
          if((v[0][0] == p.getX() and v[0][1] == p.getY()) or
             (v[1][0] == p.getX() and v[1][1] == p.getY()) or
             (v[2][0] == p.getX() and v[2][1] == p.getY()) or
             (v[3][0] == p.getX() and v[3][1] == p.getY()))
          {
            return true;
          }
          else
          {
            return false;
          }
  
      };
  };
  
  int main(){
      Point2D p(10,10);
      Point2D q(15,15);
      Point2D s(20,20);
      Point2D t(10,12);
  
      Rectangle r(p,q);
  
      r.printPointList();
  
      cout &lt;&lt; "Do rectangle 'r' and point 'p' touch = " &lt;&lt; SPALops::touches(r,p) &lt;&lt; endl;
      cout &lt;&lt; "Do rectangle 'r' and point 's' touch = " &lt;&lt; SPALops::touches(r,s) &lt;&lt; endl;
      cout &lt;&lt; "Do rectangle 'r' and point 't' touch = " &lt;&lt; SPALops::touches(r,t) &lt;&lt; endl;
  
      return 0;
  
  }
  </code></pre>
  
  <p>It seems I have many errors that stop me from running succesfully. I would appreciate if I get any feedback.</p>