Question: Need Class Diagram Assignment # 6 - Pizza Restaurant Write a C + + program ( define a class called Pizza ) that has member

Need Class Diagram
Assignment #6- Pizza Restaurant
Write a C++ program (define a class called Pizza) that has member variables to track the
type of pizza (Deep Dish, Hand-Tossed Pizza, Original Pan-Pizza or Thin 'N Crispy) along
with the size (Small, Medium, or Large), and the toppings Meat toppings (Pepperoni,
Italian Sausage, Bacon, Ham, Mushroom, Grilled Chicken, Beef, Pork) and Veggies
toppings(Mushroom, Red Onions, Black Olives, Green Peppers, Tomates)
Based on the problem, you need to design the program as follows:
Use constants to represent the type and size.
Include mutator(setter) and accessor(getter) functions for your class.
Create a void function, output Description (), that outputs a textual description of
the pizza object.
Also include a function, compute Price (), that computes the cost of the pizza and
returns it as a double according to the following rules:
Small pizza =$10+$2 per topping
Medium pizza =$14+$2 per topping
, Large pizza =$17+$2 per topping
After the order of the pizza has been inputted, describe the order in format of a
bill/receipt of purchase which will describe the type of pizza with the price, size of
pizza with the price, the toppings that the customer order with the price (describe in
line 4) and Total amount.
code:
#include
#include
#include
using namespace std;
// Declare all constants
const string TYPE_STUFF_CRUST = "Stuff-Crust";
const string TYPE_HAND_TOSSED = "Hand-Tossed Pizza";
const string TYPE_PAN_PIZZA = "Original Pan-Pizza";
const string SIZE_SMALL = "Small";
const string SIZE_MEDIUM = "Medium";
const string SIZE_LARGE = "Large";
const int PRICE_SMALL =10;
const int PRICE_MEDIUM =14;
const int PRICE_LARGE =17;
const int PRICE_TOPPINGS =2;
// Pizza class
class Pizza
{
private:
string type;
string size;
vector toppings;
double getBasePrice() const
{
double price =0;
if (getSize()== SIZE_SMALL)
{
price = PRICE_SMALL;
}
else if (getSize()== SIZE_MEDIUM)
{
price = PRICE_MEDIUM;
}
else if (getSize()== SIZE_LARGE)
{
price = PRICE_LARGE;
}
return price;
}
double getToppingsPrice() const
{
return toppings.size()* PRICE_TOPPINGS;
}
public:
Pizza(){};
void setType(string t)
{
type = t;
}
string getType() const
{
if (type =="S")
{
return TYPE_STUFF_CRUST;
}
else if (type =="H")
{
return TYPE_HAND_TOSSED;
}
else if (type =="P")
{
return TYPE_PAN_PIZZA;
}
return "";
}
void setSize(string s)
{
size = s;
}
string getSize() const
{
if (size =="S")
{
return SIZE_SMALL;
}
else if (size =="M")
{
return SIZE_MEDIUM;
}
else if (size =="L")
{
return SIZE_LARGE;
}
else
{
return "";
}
}
void addToppings(string topping)
{
toppings.push_back(topping);
}
string getToppingName(string toppingLetter)
{
string toppingName;
if (toppingLetter =="P")
{
toppingName = "Pepperoni";
}
else if (toppingLetter =="M")
{
toppingName = "Mushroom";
}
else if (toppingLetter =="S")
{
toppingName = "Sausage";
}
else if (toppingLetter =="O")
{
toppingName = "Onions";
}
else if (toppingLetter =="B")
{
toppingName = "Bacon";
}
else if (toppingLetter =="BO")
{
toppingName = "Black Olives";
}
else if (toppingLetter =="H")
{
toppingName = "Ham";
}
else if (toppingLetter =="BP")
{
toppingName = "Bell Pepper";
}
else if (toppingLetter =="GC")
{
toppingName = "Grilled Chicken";
}
else if (toppingLetter =="T")
{
toppingName = "Tomatoes";
}
else if (toppingLetter =="BF")
{
toppingName = "Beef";
}
else if (toppingLetter =="PI")
{
toppingName = "Pineapple";
}
else
{
toppingName = "Unknown";
}
return toppingName;
}
void Description() const
{
cout "Pizza Type: " getType() endl;
cout "Pizza Size: " getSize(
Need Class Diagram Assignment # 6 - Pizza

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!