Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++ with comments and follow the instructions please here is the question : T

ID: 3724265 • Letter: I

Question

In C++ with comments and follow the instructions please

here is the question :

Thanks in advance

Pizza Ordering System This lab uses vectors in TWO wavs A list of pizza orders (in the "app") A vector INSIDE the class to keep a list of pizza toppings Make sure you have a clear vision of this before you start coding. READ THE INSTRUCTIONS SEVERAL TIMES Implement this lab with THREE files (pizza.h, pizza.cpp, app.cpp) PizzasRUs needs a system to create and process customer orders. They sell pizzas in 3 sizes small, medium, large. The user can add as many toppings as they like. Pizza pricing: Small = 10, medium = 14, large = 17 Plus S2 for each topping Create a class called Pizza that can be used to process pizza orders. Required class attributes and functions are as follows Class attributes Customer name (you can make it a single name, 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 set/get for size (validate that size is only S, M, L- any case) » set/get for name » addTopping -this function receives a string representing a topping, adds to to the vector 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 in sample output Make sure you code AND TEST EACH CLASS FUNCTION FIRST. If they all work correctlv, it will be simple to "build" the app

Explanation / Answer

#ifndef PIZZA_H
#define PIZZA_H

#include <vector>
class Pizza
{
public:
// Function declarations
Pizza();
  
string getName();
void setName(string name);
void setSize(char size);
char getSize();
void addTopping(string topping);
void clearTopping();
double getPrice();
void display();
void setPrice(double price);
private:
// Declaring variables
string name;
char size;
  
double price;  
// Declaring vector
vector<string> vec;
};
#endif

___________________

#include <iostream>
#include <string>
#include <vector>
using namespace std;
#include "Pizza.h"

Pizza::Pizza()
{

}
  
string Pizza::getName()
{
return name;  
}
void Pizza::setName(string name)
{
this->name=name;
}
void Pizza::setSize(char size)
{
this->size=size;
}
char Pizza::getSize()
{
return size;
}
void Pizza::addTopping(string topping)
{
// pushing into vector
vec.push_back(topping);
}
void Pizza::clearTopping()
{
vec.clear();
}
double Pizza::getPrice()
{
return price;
}
void Pizza::setPrice(double price)
{
this->price=price;
}
void Pizza::display()
{
double sum=0.0;
cout<<"Customer name :"<<name<<endl;
if(size=='s' || size=='S')
{
cout<<"Small Pizza with "<<vec.size()<<" toppings"<<endl;
sum+=10;
}
else if(size=='m' || size=='M')
{
cout<<"Medium Pizza with "<<vec.size()<<" toppings"<<endl;
sum+=14;
}
else if(size=='L' || size=='l')
{
cout<<"Large Pizza with "<<vec.size()<<" toppings"<<endl;
sum+=17;
}

sum+=vec.size()*2;

setPrice(sum);

for(int i=0;i<vec.size();i++)
cout<<vec[i]<<" ";

cout<<"Price: $"<<price<<endl;

}
____________________

#include <iostream>
#include <string>
using namespace std;
#include "Pizza.h"

int main()
{
string name;
char size;
string toppings;
int choice;
// Declaring vector
vector<Pizza> pizza;
  
while(true)
{
cout<<" 1 - New Order"<<endl;
cout<<"2 - Show all Orders"<<endl;
cout<<"3 - Exit"<<endl;
  
cout<<" Your Choice :";
cin>>choice;
switch(choice)
{
case 1:
{
Pizza p;
  
cout<<"Enter size (S,M,L) :";
while(true)
{
cin>>size;
if(size == 'S'||size == 's'||size == 'm'|| size == 'M' || size == 'L'||size == 'l')
{
break;
}
else
{
cout<<"Invalid, re-enter:";  
continue;
}
}
  
while(true)
{
cout<<"Enter a topping, enter X when done:";
cin>>toppings;
if(toppings.compare("X")!=0)
{
p.addTopping(toppings);
continue;
}
else
break;
}
  
  
cout<<"Enter customer name :";
cin>>name;
  
  
  
p.setName(name);
p.setSize(size);
  
pizza.push_back(p);
p.display();
  
continue;
}
case 2:{
for(int i=0;i<pizza.size();i++)
{
pizza[i].display();
}
continue;
}
case 3:{
cout<<"Order Summary"<<endl;
cout<<"Customer Size Prcie"<<endl;
double sum=0;
for(int i=0;i<pizza.size();i++)
{
cout<<pizza[i].getName()<<" "<<pizza[i].getSize()<<" "<<pizza[i].getPrice();
sum+=pizza[i].getPrice();
}
cout<<"Total Sales: $"<<sum<<endl;
  
  
break;
}
}
}
  


return 0;
}

____________________