Hello, This is about an assignment and the requirements (to pass) is as follow:
1-Abstract base Class Shape must have the following consturctors:
area()
print()
Recommended constructors:
Point( double x, double y, double size)
Circle( double x, double y, double radie)
Rectangle( double x, double y, double width, double height)
Polygon(double x, double y, Vertex *varr, int num)
2-Linked list ShapeList with following recommended methods:
ShapeList()
ShapeList( const ShapeList &shapes)
~ShapeList()
add( const Shape& s ) // Add a copy of s in the list
remove( const Vertex &v) // remove all shapes "close to" v
area() // return the total area of all shapes
print() // print out the whole list
This assigment gave me this to work with as main:
#include <iostream>
using namespace std;
#include "shapelist.h"
int main()
{
ShapeList list;
Vertex varr[] = { Vertex(0,0), Vertex(10,0),
Vertex(5,2), Vertex(5,5) };
list.add( Polygon( 1, 4, varr, 4 ) );
list.add( Rectangle( 4, 10, 2, 4) );
list.add( Circle( 5,5, 3) );
list.add( Point( 6, 7, 1 ) );
list.print();
cout << " Total area: " << list.area() << endl;
ShapeList list2(list);
list2.print();
cout << " Total area: " << list2.area() << endl;
list.remove( Vertex(5,5) );
list.print();
cout << " Total area: " << list.area() << endl;
list2.print();
cout << " Total area: " << list2.area() << endl;
return 0;
}
The Program shall output:
> POLYGON:(1,4) {(0,0) (10,0) (5,2) (5,5) }
> RECTANGLE:(4,10) (2,4)
> CIRCLE:(5,5) 3
> POINT:(6,7) 1
> Total area: 54.7743
> POLYGON: (1,4) {(0,0) (10,0) (5,2) (5,5) }
> RECTANGLE: (4,10) (2,4)
> CIRCLE: (5,5) 3
> POINT: (6,7) 1
> Total area: 54.7743
> POLYGON: (1,4) {(0,0) (10,0) (5,2) (5,5) }
> RECTANGLE: (4,10) (2,4)
> POINT: (6,7) 1
> Total area: 26.5
> POLYGON: (1,4) {(0,0) (10,0) (5,2) (5,5) }
> RECTANGLE: (4,10) (2,4)
> CIRCLE: (5,5) 3
> POINT: (6,7) 1
> Total area: 54.7743
I have solved everything but:
ShapeList list2(list);
I don't know how to solve that line of code.
I appriciate any help I gain with this.
Thanks in beforehand.