This Programming Project requires you to first complete Prog

This Programming Project requires you to first complete Programming Project 7 from Chapter 5, which is an implementation of a Pizza class. Add an Order class that contains a private vector of type Pizza. This class represents a customer’s entire order, where the order may consist of multiple pizzas. Include appropriate functions so that a user of the Order class can add pizzas to the order (type is deep dish, hand tossed, or pan; size is small, medium, or large; number of pepperoni or cheese toppings). Data members: type and size. Also write a function that outputs everything in the order along with the total price. Write a suitable test program that adds multiple pizzas to an order(s).

Solution

#include<iostream>
#include <vector>
#include<string>

class Pizza
{
   private:
      
       string name, type,size ;
       float price;
   public:
       Pizza(string n, string t, string s, float pr)
       {
           name=n; type=t; size=s;
           price=pr;
       }
      
       float getPrice()
       {
           return price;
       }
      
       void toString()
       {
           cout << name<<\" \"<<type<<\" \"<<size<<\" Price: \"<<price<<endl;
       }
      
      
};

class Order
{
   private:
       std::vector<Pizza> pizs;
  
   public:
       void addPizza(Pizza p)
       {
           pizs.push_back(p);
       }
      
       void displayOrder()
       {
           Pizza *p;
           float total=0;
           for(int i=0;i<pizs.size();i++)
          
           {
       p=&pizs[i];
       p->toString();
       total=total+p->getPrice();
      
            }
       }
};

int main()
{
   Order o;
   Pizza p(\"Chicken Blast\",\"Non Veg\",\"Large\",450);
   o.addPizza(p);
   o.addPizza(Pizza(\"Chicken Blast\",\"Non Veg\",\"Small\",230));
  
   o.displayOrder();
}

This Programming Project requires you to first complete Programming Project 7 from Chapter 5, which is an implementation of a Pizza class. Add an Order class th
This Programming Project requires you to first complete Programming Project 7 from Chapter 5, which is an implementation of a Pizza class. Add an Order class th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site