Question
Define a class called Pizza that has member variables for the type of pizza (deep dish, hand tossed, or pan), size (small, medium, or large)
Define a class called Pizza that has member variables for the type of pizza (deep dish, hand tossed, or pan), size (small, medium, or large) and the number of toppings. Include mutator and accessor functions for your class. Create a function that will output a description of the pizza. Include a function that will calculate the price of your pizza: small is $10.00, medium is $14.00, and large is $17.00. Each topping costs $2.00.
Add an order class that contains a private vector of type Pizza. This class represents a customer's entire order where the order can consist of multiple pizzas, customer name, and phone number. Include appropriate functions so that a user of the order class can add pizzas to the order. Include a function that outputs the entire order along with the total price. Allow your program to add multiple pizzas to an order.
*helpful comments in the code would be greatly appreciated.
-This isn't a functional program yet but this is currently what I have as I'm still a bit confused with classes and vectors. I also realize it would be much simpler to represent each type of pizza and the size as ints and not string data types with numbers like 1 for deep dish, 2 for hand tossed, etc. and same with size.
#include
using namespace std;
class Pizza
{
private:
string type;
string size;
int numToppings;
public:
// mutator
void setType(string);
void setSize(string);
void setNumToppings(int);
// accessor
string getType(string);
string getSize(string);
int getNumToppings(int);
};
// set or mutator functions
void Pizza:: setType(string t){ type=t;}
void Pizza:: setSize(string s){ size=s;}
void Pizza:: setNumToppings(int n){ numToppings=n;}
// get or accessor functions
string Pizza:: getType(){return type;}
string Pizza:: getSize(){return size;}
int Pizza:: getNumToppings(){return numToppings ;}
//prototype
void displayData( Pizza &myPizza);
float calcPizza(string s, int n);
int main()
{
return 0;
}
// function
void displayData( Pizza &myPizza)
{
cout<< " You have a " << myPizza.type << " " << myPizza.size << " with " << myPizza.numToppings << " toppings ";
}
float calcPizza(string s, int n)
{
float cost=0;
if(size=="small" )
cost += 10.00;
else if(size=="medium" )
cost += 14.00;
else if(size=="large" )
cost += 17.00;
cost+=numToppings *2.00;
/*for(int i=0; i { cost+=2.00; }*/ return cost; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started