Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- class Automat
- {
- protected:
- vector<Automat> atm;
- int milk;
- int coffee;
- public:
- Automat(int milk = 5000, int coffee = 1500)
- {
- this->milk = milk;
- this->coffee = coffee;
- }
- void SetCoffee()
- {
- if (this->coffee == 0)
- {
- cout << "Add coffee: ";
- cin >> coffee;
- this->coffee = +coffee;
- }
- }
- void SetMilk()
- {
- if (this->milk == 0)
- {
- cout << "Add milk: ";
- cin >> milk;
- this->milk = +milk;
- }
- }
- int Getmilk() { return this->milk; }
- int GetCoffee() { return this->coffee; }
- void Show()
- {
- cout << "Automat is full: \n";
- cout << "milk: \t" << milk << '\n';
- cout << "Cofe: \t" << coffee << '\n';
- }
- };
- class Coffee :public Automat
- {
- int coffeeMilk;
- int coffeeCoffee;
- int count;
- public:
- Coffee()
- {
- coffeeMilk = 100;
- coffeeCoffee = 15;
- }
- void CookingCoffee()
- {
- cout << "What type of coffee u want? -- (latte, cappucino, ordinary)\n";
- string type_coffee;
- cin >> type_coffee;
- cout << "How many " << type_coffee << " u want?\n";
- cin >> count;
- int ost_coffee, ost_milk, ost;
- if (type_coffee == "latte") {
- coffeeMilk = 300;
- coffeeCoffee = 15;
- this->milk -= coffeeMilk * count;
- this->coffee -= coffeeCoffee * count;
- ost_coffee = this->coffee / coffeeCoffee;
- ost_milk = this->milk / coffeeMilk;
- if (ost_coffee < ost_milk) {
- ost = ost_coffee;
- }
- else {
- ost = ost_milk;
- }
- }
- if (type_coffee == "cappucino") {
- coffeeMilk = 30;
- coffeeCoffee = 30;
- this->milk -= coffeeMilk * count;
- this->coffee -= coffeeCoffee * count;
- ost_coffee = this->coffee / coffeeCoffee;
- ost_milk = this->milk / coffeeMilk;
- if (ost_coffee < ost_milk) {
- ost = ost_coffee;
- }
- else {
- ost = ost_milk;
- }
- }
- if (type_coffee == "ordinary") {
- this->milk -= coffeeMilk * count;
- this->coffee -= coffeeCoffee * count;
- ost_coffee = this->coffee / coffeeCoffee;
- ost_milk = this->milk / coffeeMilk;
- if (ost_coffee < ost_milk) {
- ost = ost_coffee;
- }
- else {
- ost = ost_milk;
- }
- }
- this->milk -= coffeeMilk * count;
- this->coffee -= coffeeCoffee * count;
- for (int i = 0; i < count; i++) {
- cout << i << " cup " << type_coffee << "\n";
- }
- cout << "U can buy " << ost << " more\n ";
- }
- };
- class Admin
- {
- Automat* tmp;
- public:
- void Add()
- {
- tmp = new Automat;
- tmp->SetMilk();
- tmp->SetCoffee();
- }
- };
- class Client :public Coffee
- {
- public:
- void DrinkCofe()
- {
- Coffee* drink = new Coffee;
- drink->CookingCoffee();
- }
- };
- int main()
- {
- Client Vova;
- cout << "PROCESS COFFEE" << "\n";
- Vova.CookingCoffee();
- Vova.GetCoffee();
- Vova.Getmilk();
- Vova.SetCoffee();
- Vova.SetMilk();
- Vova.Show();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement