#include "Point.h" #include "Circle.h" #include <iostream> using namespace std; int main() { cout << "Create point with value 1,2" << endl; Point myPoint(1,2); //creates myPoint with xCoordinate 1 and yCoordinate 2 cout << "Point: " << myPoint << endl << endl; // output myPoint coordinates cout << "Set the x-coordinate to 5 and the y-coordinate to 6" << endl; myPoint.setX(5); //set myPoint's xCoordinate to 5 myPoint.setY(6); //set myPoint's yCoordinate to 6 cout << "Point: " << myPoint << endl << endl; //Output myPoint coordinates cout << "The X-Coordinate is: " << myPoint.getX() << endl; //Print myPoint xCoordinate value cout << "The Y-Coordinate is: " << myPoint.getY() << endl << endl; //Print myPoint yCoordinate value cout << "Create a circle with a radius of 5.7 and a point of (1,2)" << endl; Circle myCircle(1,2,5.7); cout << "Circle: " << myCircle << endl << endl; cout << "Set the point to (4,6)" << endl; myCircle.setX(4); myCircle.setY(6); cout << "Circle: " << myCircle << endl << endl; return 0; }

Circle.h

#ifndef Ch2HW_MichaelRauch_Circle_h #define Ch2HW_MichaelRauch_Circle_h #include <iostream> #include "Point.h" using namespace std; class Circle: public Point { public: //Construtor Circle(double x, double y, double rad) { radius = rad; //Store the radius of the circle setX(x); //Stores the xCoordinate setY(y); //Stores the yCoordinate } private: double radius; //Variable to define radius }; #endif

Point.h

#ifndef Ch2HW_MichaelRauch_Point_h #define Ch2HW_MichaelRauch_Point_h #include <iostream> using namespace std; class Point { //Overload << operator friend ostream& operator<< (ostream&, const Point&); public: //Construtor Point(double x = 0, double y = 0) { xCoordinate = x; //Store the X value of the coordinate yCoordinate = y; //Store the Y value of the coordinate } //Function to set the y coordinate void setY(double y = 0) { yCoordinate = y; //Store new y value of the coordinate } //Function to set the x coordinate void setX(double x = 0) { xCoordinate = x; //Store new x value of the coordinate } //Function to get the y coordinate double getY() { return yCoordinate; //return the y value of the coordinate } //Function to get the x coordinate double getX() { return xCoordinate; //return the x value of the coordinate } private: double xCoordinate; //Variable to define x coordinate double yCoordinate; //Variable to define y coordinate }; //Make << output "(x,y)" ostream& operator<<(ostream& osObject, const Point& coordinate) { osObject << "("; //Current output "(" osObject << coordinate.xCoordinate; //Current output "(x" osObject << ","; //Current output "(x," osObject << coordinate.yCoordinate; //Current output "(x,y" osObject << ")"; //Current output "(x,y)" return osObject; //return osObject which contains "(x,y)" } #endif

I am getting an output of:

Create point with value 1,2

Point: (1,2)

Set the x-coordinate to 5 and the y-coordinate to 6

Point: (5,6)

The X-Coordinate is: 5

The Y-Coordinate is: 6

Create a circle with a radius of 5.7 and a point of (1,2)

Circle: (1,2)

Set the point to (4,6)

Circle: (4,6)

but i want an output of:

Create point with value 1,2

Point: (1,2)

Set the x-coordinate to 5 and the y-coordinate to 6

Point: (5,6)

The X-Coordinate is: 5

The Y-Coordinate is: 6

Create a circle with a radius of 5.7 and a point of (1,2)

Circle: (1,2,5.7)

Set the point to (4,6)

Circle: (4,6,5.7)

I have tried getting Circle.h to do this:

#ifndef Ch2HW_MichaelRauch_Circle_h #define Ch2HW_MichaelRauch_Circle_h #include <iostream> #include "Point.h" using namespace std; class Circle: public Point { public: friend ostream& operator<< (ostream&, const Circle&); //Construtor Circle(double x, double y, double rad) { radius = rad; //Store the radius of the circle setX(x); //Stores the xCoordinate setY(y); //Stores the yCoordinate } private: double radius; //Variable to define radius }; ostream& operator<<(ostream& osObject, const Circle& info) { osObject << "("; osObject << info.getX(); osObject << ","; osObject << info.getY(); osObject << ","; osObject << info.radius; osObject << ")"; return osObject; //return osObject which contains "(x,y)" } #endif

But i still do not get the output that i want....