Advertisement
Guest User

ShapeCodeTyler

a guest
Nov 13th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. //Shape.h
  2. using namespace std;
  3.  
  4. struct line{
  5. public:
  6. int thickness;
  7. string color;
  8. };
  9. struct fill{
  10. public:
  11. string color;
  12. int coord[2];
  13. };
  14.  
  15. class Shape{
  16. protected:
  17. line sLine;
  18. fill sFill;
  19.  
  20. public:
  21. Shape();
  22. int area(int base, int height, char type);
  23. int area(int length, int width);
  24. double area(double radius);
  25.  
  26. int boundaries(int base);
  27. int boundaries(int length, int width);
  28. double boundaries(double radius);
  29.  
  30. };
  31.  
  32. -------------------------------------
  33. //Shape.cpp
  34. #include <iostream>
  35. #include "Shape.h"
  36.  
  37. Shape::Shape(){
  38. sLine.thickness = 0;
  39. sLine.color = " ";
  40.  
  41. sFill.color = " ";
  42. sFill.coord[0] = 0;
  43. sFill.coord[1] = 0;
  44. }
  45.  
  46. int Shape::area(int base, int height, char type){
  47. return (base*height)/2;
  48. }
  49. int Shape::area(int length, int width){
  50. return length*width;
  51. }
  52. double Shape::area(double radius){
  53. double pi == 3.1415926535897;
  54. radius *= radius; // Square the radius
  55. return pi * radius;
  56. }
  57.  
  58. int Shape::boundaries(int base){
  59. return base*3;
  60. }
  61. int Shape::boundaries(int length, int width){
  62. return (2*length) + (2*width);
  63. }
  64. double Shape::boundaries(double radius){
  65. return 2* pi * radius;
  66. }
  67.  
  68. ----------------------------
  69. //Triangle.h
  70. #include "Shape.h"
  71.  
  72. class Triangle:public Shape{
  73. protected:
  74. int base;
  75. int height;
  76. string type;
  77.  
  78. public:
  79. Triangle();
  80. Triangle(int b, int h, string t)
  81.  
  82.  
  83. };
  84. ------------------------------
  85. //Triangle.cpp
  86. #include <iostream>
  87. #include "Triangle.h"
  88.  
  89. Triangle::Triangle(){
  90. base = 0;
  91. height = 0;
  92. type = " ";
  93. }
  94.  
  95. Triangle::Triangle(int b, height h, type t){
  96. base = b;
  97. height = h;
  98. type = t;
  99. }
  100.  
  101. ----------------------------------
  102. //Circle.h
  103. #include "Shape.h"
  104.  
  105. class Circle:public Shape(){
  106. protected:
  107. double radius;
  108.  
  109. public:
  110. Circle();
  111. Circle(double r);
  112. }
  113.  
  114. ------------------------------------------
  115. //Circle.cpp
  116. #include <iostream>
  117. #include "Circle.h"
  118.  
  119. Circle::Circle(){
  120. radius = 0.0;
  121. }
  122.  
  123. Circle::Circle(double r){
  124. radius = r;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement