Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fruit.h
- #pragma once
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <cstring>
- using namespace std;
- enum yn {no, yes};
- enum color {red, yellow, green, orange};
- class Fruit {
- public:
- enum yn annual;
- enum yn perennial;
- enum yn tree;
- enum yn tropical;
- enum color color;
- char name[40];
- };
- class Apple : public Fruit{
- enum yn cooking;
- enum yn crunchy;
- enum yn eating;
- public:
- void seta(char*, enum color, enum yn, enum yn, enum yn);
- void show();
- };
- class Orange : public Fruit {
- enum yn juice;
- enum yn sour;
- enum yn eating;
- public:
- void seto(char*, enum color, enum yn, enum yn, enum yn);
- void show();
- };
- // Fruit.cpp
- #include "Fruit.h"
- char* c[] =
- {
- "red", "yellow", "green", "orange"
- };
- void out(enum yn);
- void Apple::seta(char *name, enum color color, enum yn cooking,
- enum yn crunchy, enum yn eating)
- {
- strcpy(this->name, name);
- annual = no;
- perennial = yes;
- tree = yes;
- tropical = no;
- this->color = color;
- this->cooking = cooking;
- this->crunchy = crunchy;
- this->eating = eating;
- }
- void Orange::seto(char *name, enum color color, enum yn juice,
- enum yn sour, enum yn eating)
- {
- strcpy(this->name, name);
- annual = no;
- perennial = yes;
- tree = yes;
- tropical = yes;
- this->color = color;
- this->juice = juice;
- this->sour = sour;
- this->eating = eating;
- }
- void Apple::show()
- {
- cout << name << " яблоко — это: " << "n";
- cout << "Однолетнее растение: "; out(annual);
- cout << "Многолетнее растение: "; out(perennial);
- cout << "Дерево: "; out(tree);
- cout << "Тропическое: "; out(tropical);
- cout << "Цвет: " << c[color] << "n";
- cout << "Легко приготавливается: "; out(cooking);
- cout << "Хрустит на зубах: "; out(crunchy);
- cout << "Съедобное: "; out(eating);
- cout << endl;
- }
- void Orange::show()
- {
- cout << name << " яблоко — это: " << "n";
- cout << "Однолетнее растение: "; out(annual);
- cout << "Многолетнее растение: "; out(perennial);
- cout << "Дерево: "; out(tree);
- cout << "Тропическое: "; out(tropical);
- cout << "Цвет: " << c[color] << "n";
- cout << "Годится для приготовления сока: "; out(juice);
- cout << "Кислый: "; out(sour);
- cout << "Съедобное: "; out(eating);
- cout << endl;
- }
- void out( enum yn x)
- {
- if (x == no) cout << "нет" << endl;
- else cout << "да" << endl;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement