1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex8.3/main.cpp
Eric Teunis de Boone 78d6fb4e3c Finished Ex8.*
2020-01-06 19:07:30 +01:00

57 lines
1.1 KiB
C++

#include <iostream>
#include <list>
#include "Shape.hh"
#include "Square.hh"
#include "Circle.hh"
using namespace std;
void listShapes( list<Shape*> l );
int main() {
Square square(5);
cout << "Square" << endl;
cout << "Surface : " << square.surface() << endl;
cout << "Circumference : " << square.circumference() << endl;
cout << endl;
Circle circle(3);
cout << "Circle" << endl;
cout << "Surface : " << circle.surface() << endl;
cout << "Circumference : " << circle.circumference() << endl;
// Shape List
list<Shape*> l;
// Create Circles
for ( int i = 0 ; i < 4 ; i++ ) {
l.push_back( new Circle(i*i) );
}
// Create Squares
for ( int i = 0 ; i < 5 ; i++ ) {
l.push_back( new Square(i*i) );
}
// List all Shapes
listShapes( l );
// Delete Shapes
for ( auto it = l.begin() ; it != l.end() ; ++it ) {
delete (*it);
}
}
void listShapes( list<Shape*> l ) {
for ( auto it = l.begin() ; it != l.end() ; ++it ) {
cout << (*it)->shapeName() << endl;
cout << "Surface : " << (*it)->surface() << endl;
cout << "Circumference : " << (*it)->circumference() << endl;
cout << endl;
}
}