#include<iostream>
#include<string>
#include<vector>
usingnamespace std;
class MyPizza
{
private:
string name;
string size;
vector<string> toppings;
public:
void setSize(string);
string getSize();
void setName(string);
string getName();
string addTopping();
MyPizza()
{
name="";
size="";
toppings.push_back("");
}//default constructor
MyPizza(string Cname, string PizzaSize,vector<string> P_toppings) //parametized constructor
{
name=Cname;
size=PizzaSize;
toppings=P_toppings;
}
};
void MyPizza::setSize(string Psize)
{
size=Psize;
}
string MyPizza::getSize()
{
return size;
}
void MyPizza::setName(string Pname)
{
name=Pname;
}
string MyPizza::getName()
{
return name;
}
string MyPizza::addTopping()
{
// addTopping – this function receives a string representing a single topping, and adds it to
//to the vector of toppings in the class
}
int main()
{
}
/*Create a class called Pizza that represents a single pizza order. Required class attributes and
functions are as follows:
Class attributes:
Customer name (you can make it a single name if you want, no spaces)
Size of pizza (you decide whether to use string or char)
A VECTOR of strings that represents the toppings
Class Functions:
Default constructor (choose appropriate values)
set/get for size (validate that size is only S, M, L – upper or case)
set/get for customer name
addTopping – this function receives a string representing a single topping, and adds it to
to the vector of toppings in the class
clearTopping – this function resets the topping vector to empty (use .clear() function)
getPrice – this function calculates are returns the price of the pizza
display – this function displays the pizza order in the format shown below:
*/
// Create a class called Pizza that represents a single pizza order.
// Required class attributes and functions are as follows:
// Class attributes:
// Customer name (you can make it a single name if you want, no spaces)
// Size of pizza (you decide whether to use std::string or char)
// A VECTOR of std::strings that represents the toppings
// Class Functions:
// Default constructor (choose appropriate values)
// set/get for size (validate that size is only S, M, L – upper or case)
// set/get for customer name
// addTopping – this function receives a std::string representing a single
// topping, and adds it to the std::vector of toppings in the class
// clearTopping – this function resets the topping std::vector to empty
// (use .clear() function)
// getPrice – this function calculates are returns the price of the pizza
// display – this function displays the pizza order in the format shown below:
#include <iostream>
#include <string>
#include <vector>
class MyPizza /* ?? Create a class called Pizza */
{
private:
std::string name;
std::string size;
std::vector<std::string> toppings;
public:
MyPizza() //default constructor
{
}
MyPizza(std::string c_name,
std::string pizza_size,
std::vector<std::string> p_toppings) //parametized constructor
{
name = c_name;
size = pizza_size;
toppings = p_toppings;
}
void setSize(const std::string & p_size);
std::string getSize() const;
void setName(const std::string & p_name);
std::string getName() const;
void addTopping(const std::string & topping);
};
void MyPizza::setSize(const std::string & p_size)
{
// Assignement requires:
/* validate that size is only S, M, L – upper or case */
size = p_size;
}
std::string MyPizza::getSize() const
{
return size;
}
void MyPizza::setName(const std::string & p_name)
{
name = p_name;
}
std::string MyPizza::getName() const
{
return name;
}
void MyPizza::addTopping(const std::string & topping)
{
// addTopping – this function receives a std::string representing a single
// topping, and adds it to the std::vector of toppings in the class
}
int main()
{
}