Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Shape.h
- using namespace std;
- struct line{
- public:
- int thickness;
- string color;
- };
- struct fill{
- public:
- string color;
- int coord[2];
- };
- class Shape{
- protected:
- line sLine;
- fill sFill;
- public:
- Shape();
- int area(int base, int height, char type);
- int area(int length, int width);
- double area(double radius);
- int boundaries(int base);
- int boundaries(int length, int width);
- double boundaries(double radius);
- };
- -------------------------------------
- //Shape.cpp
- #include <iostream>
- #include "Shape.h"
- Shape::Shape(){
- sLine.thickness = 0;
- sLine.color = " ";
- sFill.color = " ";
- sFill.coord[0] = 0;
- sFill.coord[1] = 0;
- }
- int Shape::area(int base, int height, char type){
- return (base*height)/2;
- }
- int Shape::area(int length, int width){
- return length*width;
- }
- double Shape::area(double radius){
- double pi == 3.1415926535897;
- radius *= radius; // Square the radius
- return pi * radius;
- }
- int Shape::boundaries(int base){
- return base*3;
- }
- int Shape::boundaries(int length, int width){
- return (2*length) + (2*width);
- }
- double Shape::boundaries(double radius){
- return 2* pi * radius;
- }
- ----------------------------
- //Triangle.h
- #include "Shape.h"
- class Triangle:public Shape{
- protected:
- int base;
- int height;
- string type;
- public:
- Triangle();
- Triangle(int b, int h, string t)
- };
- ------------------------------
- //Triangle.cpp
- #include <iostream>
- #include "Triangle.h"
- Triangle::Triangle(){
- base = 0;
- height = 0;
- type = " ";
- }
- Triangle::Triangle(int b, height h, type t){
- base = b;
- height = h;
- type = t;
- }
- ----------------------------------
- //Circle.h
- #include "Shape.h"
- class Circle:public Shape(){
- protected:
- double radius;
- public:
- Circle();
- Circle(double r);
- }
- ------------------------------------------
- //Circle.cpp
- #include <iostream>
- #include "Circle.h"
- Circle::Circle(){
- radius = 0.0;
- }
- Circle::Circle(double r){
- radius = r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement