Sunteți pe pagina 1din 2

#include <string>

#include <iostream>
using namespace std;
class Tea{
protected : double price,totalPrice ;
int numtop, size;
public :
void teaSize(int z,int t)
{
size = z;
numtop = t;
switch (size)
{
case 1:
price = 5.00;
break;
case 2:
price = 8.00;
break;
case 3:
price = 12.00;
break;
default: cout << "Invalid number" << endl ;
};

}
virtual double calculatePrice() = 0;
void display()
{
calculatePrice();
cout << "Total Price : " << totalPrice << " Size : " << size << " Topping : " <<
numtop << endl;
};

class calledTeonMenu : public Tea


{
public :
double calculatePrice()
{
if (numtop == 1)
totalPrice = price + 2;
else
totalPrice = price;
}

return totalPrice;

void display()
{
cout << "CustomizeF tea : " << totalPrice << endl;
}
};
class CustomizeTea : public Tea
{
double calculatePrice()
{
double priceTopping = numtop * 1.5;
totalPrice = price + priceTopping ;
}

return totalPrice;

};
void main()
{
calledTeonMenu z;
CustomizeTea f;
Tea *tea1 = &z;
Tea *tea2 = &f;

tea1->teaSize(1,0);
tea2->teaSize(3,2);
tea1->display();
tea2->display();

system("PAUSE");
}

S-ar putea să vă placă și