AgustinMayta

cacacacac

Sep 27th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.92 KB | None | 0 0
  1. #pragma once
  2. #include "Poliedro.h"
  3. class COctaedro : public CPoliedro
  4. {
  5. public:
  6.     COctaedro(int _a);
  7.     ~COctaedro();
  8.     void Volumen();
  9.     void Area();
  10. };
  11.  
  12. #include "stdafx.h"
  13. #include "Octaedro.h"
  14.  
  15.  
  16. COctaedro::COctaedro(int _a) :CPoliedro(_a)
  17. {
  18.  
  19. }
  20.  
  21.  
  22. COctaedro::~COctaedro()
  23. {
  24. }
  25. void COctaedro::Volumen()
  26. {
  27.     float volumen;
  28.     volumen = a*a*a * 2 / 3;
  29.     cout << "Volumen es : " << volumen;
  30. }
  31. void COctaedro::Area()
  32. {
  33.     float area;
  34.     area = 2 * a*a*sqrt(3);
  35.     cout << "Area es : " << area;
  36. }
  37. #pragma once
  38. #include "Poliedro.h"
  39. class CHexaedro : public CPoliedro
  40. {
  41. public:
  42.     CHexaedro(int _a);
  43.     ~CHexaedro();
  44.     void Volumen();
  45.     void Area();
  46. };
  47.  
  48. #include "stdafx.h"
  49. #include "Hexaedro.h"
  50.  
  51.  
  52. CHexaedro::CHexaedro(int _a) :CPoliedro(_a)
  53. {
  54. }
  55.  
  56.  
  57. CHexaedro::~CHexaedro()
  58. {
  59. }
  60. void CHexaedro::Volumen()
  61. {
  62.     float volumen;
  63.     volumen = a*a*a;
  64.     cout << "Volumen es : " << volumen;
  65. }
  66. void CHexaedro::Area()
  67. {
  68.     float area;
  69.     area = 6 * a*a;
  70.     cout << "Area es : " << area;
  71. }
  72. #pragma once
  73. #include "Poliedro.h"
  74. class CTetraedro :public CPoliedro
  75. {
  76. public:
  77.     CTetraedro(int _a);
  78.     ~CTetraedro();
  79.     void Area();
  80.     void Volumen();
  81. };
  82.  
  83. #include "stdafx.h"
  84. #include "Tetraedro.h"
  85.  
  86.  
  87. CTetraedro::CTetraedro(int _a):CPoliedro(_a)
  88. {
  89. }
  90.  
  91.  
  92. CTetraedro::~CTetraedro()
  93. {
  94. }
  95.  
  96. void CTetraedro::Area()
  97. {
  98.     float area;
  99.     area = a*a*sqrt(3);
  100.     cout << "Area es : " << area;
  101. }
  102.  
  103. void CTetraedro::Volumen()
  104. {
  105.     float volumen;
  106.     volumen = (a*a*a*sqrt(2)) / 2;
  107.     cout << "Volumen es : " << volumen;
  108. }
  109. // stdafx.h : include file for standard system include files,
  110. // or project specific include files that are used frequently, but
  111. // are changed infrequently
  112. //
  113.  
  114. #pragma once
  115.  
  116. #include <iostream>
  117. #include <conio.h>
  118. #include "Poliedro.h"
  119. #include "Tetraedro.h"
  120. #include "Octaedro.h"
  121. #include "Hexaedro.h"
  122. using namespace System;
  123. using namespace std;
  124. // TODO: reference additional headers your program requires here
  125. #pragma once
  126. class CPoliedro
  127. {
  128. protected:
  129.     int a;
  130. public:
  131.     CPoliedro(int _a);
  132.     ~CPoliedro();
  133. };
  134.  
  135. #include "stdafx.h"
  136. #include "Poliedro.h"
  137.  
  138.  
  139. CPoliedro::CPoliedro(int _a)
  140. {
  141.     a = _a;
  142. }
  143.  
  144.  
  145. CPoliedro::~CPoliedro()
  146. {
  147. }
  148. // ConsoleApplication2.cpp : main project file.
  149.  
  150. #include "stdafx.h"
  151. void Menu()
  152. {
  153.     cout << endl << "-----------Menu-----------" << endl;
  154.     cout << "1. Tetraedro" << endl;
  155.     cout << "2. Hexaedro" << endl;
  156.     cout << "3. Octaedro" << endl;
  157.     cout << endl;
  158. }
  159. int main()
  160. {
  161.     int opc;
  162.     int a;
  163.     CTetraedro* obj1;
  164.     CHexaedro* obj2;
  165.     COctaedro* obj3;
  166.     while (1)
  167.     {
  168.         Menu();
  169.         cin >> opc;
  170.         cout << "Ingrese Arista : " << endl;
  171.         cin >> a;
  172.         switch (opc)
  173.         {
  174.         case 1:
  175.             obj1 = new CTetraedro(a);
  176.             obj1->Volumen();
  177.             obj1->Area();
  178.             break;
  179.         case 2:
  180.            
  181.             obj2 = new CHexaedro(a);
  182.             obj2->Volumen();
  183.             obj2->Area();
  184.             break;
  185.         case 3:
  186.             obj3 = new COctaedro(a);
  187.             obj3->Volumen();
  188.             obj3->Area();
  189.             break;
  190.         }
  191.     }
  192.     _getch();
  193.     return 0;
  194. }
Advertisement
Add Comment
Please, Sign In to add comment