Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. // Fruit.h
  2. #pragma once
  3.  
  4. #define _CRT_SECURE_NO_WARNINGS
  5.  
  6. #include <iostream>
  7. #include <cstring>
  8. using namespace std;
  9.  
  10.  
  11. enum yn {no, yes};
  12. enum color {red, yellow, green, orange};
  13.  
  14. class Fruit {
  15. public:
  16. enum yn annual;
  17. enum yn perennial;
  18. enum yn tree;
  19. enum yn tropical;
  20. enum color color;
  21. char name[40];
  22. };
  23.  
  24. class Apple : public Fruit{
  25. enum yn cooking;
  26. enum yn crunchy;
  27. enum yn eating;
  28. public:
  29. void seta(char*, enum color, enum yn, enum yn, enum yn);
  30. void show();
  31. };
  32.  
  33. class Orange : public Fruit {
  34. enum yn juice;
  35. enum yn sour;
  36. enum yn eating;
  37. public:
  38. void seto(char*, enum color, enum yn, enum yn, enum yn);
  39. void show();
  40. };
  41.  
  42.  
  43.  
  44. // Fruit.cpp
  45. #include "Fruit.h"
  46.  
  47. char* c[] =
  48. {
  49. "red", "yellow", "green", "orange"
  50. };
  51.  
  52. void out(enum yn);
  53.  
  54. void Apple::seta(char *name, enum color color, enum yn cooking,
  55. enum yn crunchy, enum yn eating)
  56. {
  57. strcpy(this->name, name);
  58. annual = no;
  59. perennial = yes;
  60. tree = yes;
  61. tropical = no;
  62. this->color = color;
  63. this->cooking = cooking;
  64. this->crunchy = crunchy;
  65. this->eating = eating;
  66. }
  67.  
  68. void Orange::seto(char *name, enum color color, enum yn juice,
  69. enum yn sour, enum yn eating)
  70. {
  71. strcpy(this->name, name);
  72. annual = no;
  73. perennial = yes;
  74. tree = yes;
  75. tropical = yes;
  76. this->color = color;
  77. this->juice = juice;
  78. this->sour = sour;
  79. this->eating = eating;
  80. }
  81.  
  82. void Apple::show()
  83. {
  84. cout << name << " яблоко — это: " << "n";
  85. cout << "Однолетнее растение: "; out(annual);
  86. cout << "Многолетнее растение: "; out(perennial);
  87. cout << "Дерево: "; out(tree);
  88. cout << "Тропическое: "; out(tropical);
  89. cout << "Цвет: " << c[color] << "n";
  90. cout << "Легко приготавливается: "; out(cooking);
  91. cout << "Хрустит на зубах: "; out(crunchy);
  92. cout << "Съедобное: "; out(eating);
  93. cout << endl;
  94. }
  95.  
  96. void Orange::show()
  97. {
  98. cout << name << " яблоко — это: " << "n";
  99. cout << "Однолетнее растение: "; out(annual);
  100. cout << "Многолетнее растение: "; out(perennial);
  101. cout << "Дерево: "; out(tree);
  102. cout << "Тропическое: "; out(tropical);
  103. cout << "Цвет: " << c[color] << "n";
  104. cout << "Годится для приготовления сока: "; out(juice);
  105. cout << "Кислый: "; out(sour);
  106. cout << "Съедобное: "; out(eating);
  107. cout << endl;
  108. }
  109.  
  110. void out( enum yn x)
  111. {
  112. if (x == no) cout << "нет" << endl;
  113. else cout << "да" << endl;
  114. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement