Class Shape
-
This is the output I am supposed to get but I am getting errors please help me
int main()
{
int size = 5;Shape\*\* shapes = new Shape\*\[size\]; Point\* centre = new Point(5,5); Rectangle\* rectangle1 = new Rectangle(\*centre, 4, 3); shapes\[0\] = rectangle1; shapes\[1\] = new Rectangle (\*new Point(10, -10), 4, 4); Rectangle\* rectangle3 = new Square(\*new Point(-8.5,-10), 2.5); shapes\[2\] = rectangle3; Square\* square2 = new Square (\*new Point(-1,-1), 1.5); shapes\[3\] = square2; Circle\* circle = new Circle(\*new Point(100,100), 25.4); shapes\[4\] = circle; cout << "\\n11111111111111111111111111\\n"; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n22222222222222222222222222\\n"; cout << "\\nthe area of the first rectangle is: "; cout << rectangle1->area() << endl; cout << "It is a square, the area is: "; Square\* square = dynamic\_cast<Square\*> (rectangle3); cout << square->area() << endl; cout << "the perimeter of the circle is: "; cout << circle->perimeter() << endl; cout << "\\n33333333333333333333333333\\n"; cout << "\\nThe four vertices of the first rectangle are: (clockwise from top-left)\\n"; rectangle1->printFourVertices(); cout << "\\nThe four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n44444444444444444444444444\\n"; rectangle1->reflectX(); shapes\[2\] -> translate(1.5, 3); shapes\[4\] -> translate(-100,-100); cout << "\\nAfter reflection and translation, here are the moved shapes:\\n" ; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n55555555555555555555555555\\n"; cout << "\\nNow, the four vertices of the first rectangle are:\\n"; rectangle1->printFourVertices(); cout << "\\nNow, the four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n66666666666666666666666666\\n\\n"; for (int i = 0; i < size; ++i) cout << shapes\[i\] -> area() << endl; // From the following statements, understand how setLength() and setWidth() // work for rectangles and squares. cout << "\\n777777777777777777777777777\\n"; shapes\[1\] -> display(); dynamic\_cast<Rectangle\*> (shapes\[1\]) -> setLength(8.2); cout << "\\nAfter setLength(8.2), the rectangle is: "; shapes\[1\] -> dis
-
This is the output I am supposed to get but I am getting errors please help me
int main()
{
int size = 5;Shape\*\* shapes = new Shape\*\[size\]; Point\* centre = new Point(5,5); Rectangle\* rectangle1 = new Rectangle(\*centre, 4, 3); shapes\[0\] = rectangle1; shapes\[1\] = new Rectangle (\*new Point(10, -10), 4, 4); Rectangle\* rectangle3 = new Square(\*new Point(-8.5,-10), 2.5); shapes\[2\] = rectangle3; Square\* square2 = new Square (\*new Point(-1,-1), 1.5); shapes\[3\] = square2; Circle\* circle = new Circle(\*new Point(100,100), 25.4); shapes\[4\] = circle; cout << "\\n11111111111111111111111111\\n"; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n22222222222222222222222222\\n"; cout << "\\nthe area of the first rectangle is: "; cout << rectangle1->area() << endl; cout << "It is a square, the area is: "; Square\* square = dynamic\_cast<Square\*> (rectangle3); cout << square->area() << endl; cout << "the perimeter of the circle is: "; cout << circle->perimeter() << endl; cout << "\\n33333333333333333333333333\\n"; cout << "\\nThe four vertices of the first rectangle are: (clockwise from top-left)\\n"; rectangle1->printFourVertices(); cout << "\\nThe four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n44444444444444444444444444\\n"; rectangle1->reflectX(); shapes\[2\] -> translate(1.5, 3); shapes\[4\] -> translate(-100,-100); cout << "\\nAfter reflection and translation, here are the moved shapes:\\n" ; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n55555555555555555555555555\\n"; cout << "\\nNow, the four vertices of the first rectangle are:\\n"; rectangle1->printFourVertices(); cout << "\\nNow, the four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n66666666666666666666666666\\n\\n"; for (int i = 0; i < size; ++i) cout << shapes\[i\] -> area() << endl; // From the following statements, understand how setLength() and setWidth() // work for rectangles and squares. cout << "\\n777777777777777777777777777\\n"; shapes\[1\] -> display(); dynamic\_cast<Rectangle\*> (shapes\[1\]) -> setLength(8.2); cout << "\\nAfter setLength(8.2), the rectangle is: "; shapes\[1\] -> dis
Do not repost questions, you have already posted the same question here, [Class shape and related functions](https://www.codeproject.com/Questions/1197886/Class-shape-and-related-functions). If someone is active to answer your question, they will do it. If there is no one, reposting the question doesn't help at all.
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
This is the output I am supposed to get but I am getting errors please help me
int main()
{
int size = 5;Shape\*\* shapes = new Shape\*\[size\]; Point\* centre = new Point(5,5); Rectangle\* rectangle1 = new Rectangle(\*centre, 4, 3); shapes\[0\] = rectangle1; shapes\[1\] = new Rectangle (\*new Point(10, -10), 4, 4); Rectangle\* rectangle3 = new Square(\*new Point(-8.5,-10), 2.5); shapes\[2\] = rectangle3; Square\* square2 = new Square (\*new Point(-1,-1), 1.5); shapes\[3\] = square2; Circle\* circle = new Circle(\*new Point(100,100), 25.4); shapes\[4\] = circle; cout << "\\n11111111111111111111111111\\n"; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n22222222222222222222222222\\n"; cout << "\\nthe area of the first rectangle is: "; cout << rectangle1->area() << endl; cout << "It is a square, the area is: "; Square\* square = dynamic\_cast<Square\*> (rectangle3); cout << square->area() << endl; cout << "the perimeter of the circle is: "; cout << circle->perimeter() << endl; cout << "\\n33333333333333333333333333\\n"; cout << "\\nThe four vertices of the first rectangle are: (clockwise from top-left)\\n"; rectangle1->printFourVertices(); cout << "\\nThe four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n44444444444444444444444444\\n"; rectangle1->reflectX(); shapes\[2\] -> translate(1.5, 3); shapes\[4\] -> translate(-100,-100); cout << "\\nAfter reflection and translation, here are the moved shapes:\\n" ; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n55555555555555555555555555\\n"; cout << "\\nNow, the four vertices of the first rectangle are:\\n"; rectangle1->printFourVertices(); cout << "\\nNow, the four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n66666666666666666666666666\\n\\n"; for (int i = 0; i < size; ++i) cout << shapes\[i\] -> area() << endl; // From the following statements, understand how setLength() and setWidth() // work for rectangles and squares. cout << "\\n777777777777777777777777777\\n"; shapes\[1\] -> display(); dynamic\_cast<Rectangle\*> (shapes\[1\]) -> setLength(8.2); cout << "\\nAfter setLength(8.2), the rectangle is: "; shapes\[1\] -> dis
-
This is the output I am supposed to get but I am getting errors please help me
int main()
{
int size = 5;Shape\*\* shapes = new Shape\*\[size\]; Point\* centre = new Point(5,5); Rectangle\* rectangle1 = new Rectangle(\*centre, 4, 3); shapes\[0\] = rectangle1; shapes\[1\] = new Rectangle (\*new Point(10, -10), 4, 4); Rectangle\* rectangle3 = new Square(\*new Point(-8.5,-10), 2.5); shapes\[2\] = rectangle3; Square\* square2 = new Square (\*new Point(-1,-1), 1.5); shapes\[3\] = square2; Circle\* circle = new Circle(\*new Point(100,100), 25.4); shapes\[4\] = circle; cout << "\\n11111111111111111111111111\\n"; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n22222222222222222222222222\\n"; cout << "\\nthe area of the first rectangle is: "; cout << rectangle1->area() << endl; cout << "It is a square, the area is: "; Square\* square = dynamic\_cast<Square\*> (rectangle3); cout << square->area() << endl; cout << "the perimeter of the circle is: "; cout << circle->perimeter() << endl; cout << "\\n33333333333333333333333333\\n"; cout << "\\nThe four vertices of the first rectangle are: (clockwise from top-left)\\n"; rectangle1->printFourVertices(); cout << "\\nThe four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n44444444444444444444444444\\n"; rectangle1->reflectX(); shapes\[2\] -> translate(1.5, 3); shapes\[4\] -> translate(-100,-100); cout << "\\nAfter reflection and translation, here are the moved shapes:\\n" ; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n55555555555555555555555555\\n"; cout << "\\nNow, the four vertices of the first rectangle are:\\n"; rectangle1->printFourVertices(); cout << "\\nNow, the four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n66666666666666666666666666\\n\\n"; for (int i = 0; i < size; ++i) cout << shapes\[i\] -> area() << endl; // From the following statements, understand how setLength() and setWidth() // work for rectangles and squares. cout << "\\n777777777777777777777777777\\n"; shapes\[1\] -> display(); dynamic\_cast<Rectangle\*> (shapes\[1\]) -> setLength(8.2); cout << "\\nAfter setLength(8.2), the rectangle is: "; shapes\[1\] -> dis
kumn1d wrote:
This is the output I am supposed to get but I am getting errors please help me
What error? The compiler ones? - Then show us the errors. Or you meant the incorrect output? - Then try to debug your code.
-
This is the output I am supposed to get but I am getting errors please help me
int main()
{
int size = 5;Shape\*\* shapes = new Shape\*\[size\]; Point\* centre = new Point(5,5); Rectangle\* rectangle1 = new Rectangle(\*centre, 4, 3); shapes\[0\] = rectangle1; shapes\[1\] = new Rectangle (\*new Point(10, -10), 4, 4); Rectangle\* rectangle3 = new Square(\*new Point(-8.5,-10), 2.5); shapes\[2\] = rectangle3; Square\* square2 = new Square (\*new Point(-1,-1), 1.5); shapes\[3\] = square2; Circle\* circle = new Circle(\*new Point(100,100), 25.4); shapes\[4\] = circle; cout << "\\n11111111111111111111111111\\n"; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n22222222222222222222222222\\n"; cout << "\\nthe area of the first rectangle is: "; cout << rectangle1->area() << endl; cout << "It is a square, the area is: "; Square\* square = dynamic\_cast<Square\*> (rectangle3); cout << square->area() << endl; cout << "the perimeter of the circle is: "; cout << circle->perimeter() << endl; cout << "\\n33333333333333333333333333\\n"; cout << "\\nThe four vertices of the first rectangle are: (clockwise from top-left)\\n"; rectangle1->printFourVertices(); cout << "\\nThe four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n44444444444444444444444444\\n"; rectangle1->reflectX(); shapes\[2\] -> translate(1.5, 3); shapes\[4\] -> translate(-100,-100); cout << "\\nAfter reflection and translation, here are the moved shapes:\\n" ; for (int i = 0; i < size; ++i) shapes\[i\] -> display(); cout << "\\n55555555555555555555555555\\n"; cout << "\\nNow, the four vertices of the first rectangle are:\\n"; rectangle1->printFourVertices(); cout << "\\nNow, the four vertices of the third rectangle are:\\n"; rectangle3->printFourVertices(); cout << "\\n66666666666666666666666666\\n\\n"; for (int i = 0; i < size; ++i) cout << shapes\[i\] -> area() << endl; // From the following statements, understand how setLength() and setWidth() // work for rectangles and squares. cout << "\\n777777777777777777777777777\\n"; shapes\[1\] -> display(); dynamic\_cast<Rectangle\*> (shapes\[1\]) -> setLength(8.2); cout << "\\nAfter setLength(8.2), the rectangle is: "; shapes\[1\] -> dis
There does not seem to be a
Rectangle::printFourVertices()
method. There is a redundant assignment operator in thePoint::setX()
method. Short of that, what's the issue? "I am getting errors" is meaningless."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
There does not seem to be a
Rectangle::printFourVertices()
method. There is a redundant assignment operator in thePoint::setX()
method. Short of that, what's the issue? "I am getting errors" is meaningless."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
kumn1d wrote:
This is the output I am supposed to get but I am getting errors please help me
What error? The compiler ones? - Then show us the errors. Or you meant the incorrect output? - Then try to debug your code.
-
I corrected the entire code , but the only thing now I dont know is how to implement this Print four Vertices function . I want to know how to implement anf declare this function . Beside that , I corrected the rest of code
How would you do it using pencil and paper? If you coded up everything that calculates said vertices, printing them should be a non-issue, yes?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles