Answer:
see explaination
Step-by-step explanation:
include <iostream>
#include <string>
using namespace std;
using namespace std;
const int SMALL = 1;
const int MEDIUM = 2;
const int LARGE = 3;
const int DEEPDISH = 1;
const int HANDTOSSED = 2;
const int PAN = 3;
class Pizza
{
private:
int type;
int size;
bool cheeseToppings;
bool pepperoniToppings;
public:
Pizza();
int getType();
int getSize();
bool getCheeze();
bool getPepperoni();
void setType(int t);
void setSize(int s);
void setCheese(bool choice);
void setPepperoni(bool choice);
void outputDescription();
double computePrice();
};
Pizza::Pizza()
{
type = DEEPDISH;
size = SMALL;
cheeseToppings = pepperoniToppings = false;
}
int Pizza::getType()
{
return type;
}
int Pizza::getSize()
{
return size;
}
bool Pizza::getCheeze()
{
return cheeseToppings;
}
bool Pizza::getPepperoni()
{
return pepperoniToppings;
}
void Pizza::setType(int t)
{
type = t;
}
void Pizza::setSize(int s)
{
size = s;
}
void Pizza::setCheese(bool choice)
{
cheeseToppings = choice;
}
void Pizza::setPepperoni(bool choice)
{
pepperoniToppings = choice;
}
void Pizza::outputDescription()
{
switch (size)
{
case SMALL:
cout << "Small "; break;
case MEDIUM:
cout << "Medium "; break;
case LARGE:
cout << "Large "; break;
default:
cout << "Unknown sized ";
}
switch (type)
{
case DEEPDISH:
cout << "deepdish "; break;
case HANDTOSSED:
cout << "hand tossed "; break;
case PAN:
cout << "pan "; break;
default:
cout << "unknown type ";
}
cout << "pizza";
}
double Pizza::computePrice()
{
double pizzaCost = 0.0;
switch (size)
{
case SMALL:
pizzaCost += 10;
break;
case MEDIUM:
pizzaCost += 14;
break;
case LARGE:
pizzaCost += 17;
break;
}
if (cheeseToppings)
pizzaCost += 2.0;
if (pepperoniToppings)
pizzaCost += 2.0;
return pizzaCost;
}
int main()
{
char pizzaType, pizzaSize, pizzaTopping;
int type = 0, size = 0;
cout << "What size pizza would you like (S/M/L): ";
cin >> pizzaSize;
cin.clear();
switch(pizzaSize)
{
case 'S': case 's':
size = SMALL; break;
case 'M': case 'm':
size = MEDIUM; break;
case 'L': case 'l':
size = LARGE; break;
}
cout << "What type pizza would you like ((D)eepdish/(H)and-tossed/(P)an): ";
cin >> pizzaType;
cin.clear();
switch(pizzaType)
{
case 'D': case 'd':
type = DEEPDISH; break;
case 'H': case 'h':
type = HANDTOSSED; break;
case 'P': case 'p':
type = PAN; break;
}
Pizza cheesy;
cheesy.setSize(size);
cheesy.setType(type);
cout << "Would you like cheese topping (y/n)? ";
cin >> pizzaTopping;
cin.clear();
if (pizzaTopping == 'Y' || pizzaTopping == 'y')
cheesy.setCheese(true);
cout << "Would you like pepperoni topping (y/n)? ";
cin >> pizzaTopping;
cin.clear();
if (pizzaTopping == 'Y' || pizzaTopping == 'y')
cheesy.setPepperoni(true);
cout << endl
<< "Your order: ";
cheesy.outputDescription();
cout << endl;
cout << "Price: $" << cheesy.computePrice() << endl;
return 0;
}
/*
output:
What size pizza would you like (S/M/L): L
What type pizza would you like ((D)eepdish/(H)and-tossed/(P)an): P
Would you like cheese topping (y/n)? y
Would you like pepperoni topping (y/n)? y
Your order: Large pan pizza
Price: $21
*/