Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Adeeb Khadem
- //3-25-2012
- //Creates specialty pizza classes, then tests them
- #include <iostream>
- #include "Pizza.h"
- using namespace std;
- class specialtyPizza: public Pizza{ //Create class
- private:
- string m_topping1;
- string m_topping2;
- string m_topping3;
- public:
- void setTopping1(string);
- string getTopping1();
- void setTopping2(string);
- string getTopping2();
- void setTopping3(string);
- string getTopping3();
- void DisplayToppings();
- void Display();
- float computePrice();
- specialtyPizza();
- specialtyPizza(string, string, string, string, string);
- };
- specialtyPizza::specialtyPizza() //Define methods
- {
- m_size = "small";
- m_type = "hand tossed";
- m_topping1 = "";
- m_topping2 = "";
- m_topping3 = "";
- }
- specialtyPizza::specialtyPizza(string size, string type, string topping1a, string topping2a, string topping3a) //Define methods
- {
- m_size = size;
- m_type = type;
- m_topping1 = topping1a;
- m_topping2 = topping2a;
- m_topping3 = topping3a;
- }
- void specialtyPizza::setTopping1(string topping1) //Topping variables
- {
- m_topping1 = topping1;
- }
- void specialtyPizza::setTopping2(string topping2)
- {
- m_topping2 = topping2;
- }
- void specialtyPizza::setTopping3(string topping3)
- {
- m_topping3 = topping3;
- }
- void specialtyPizza::Display()
- {
- cout << m_size << " " << m_type << " " << m_topping1 << " " << m_topping2 << " " << m_topping3 << " $" << computePrice() << endl;
- }
- void specialtyPizza::DisplayToppings()
- {
- cout << "The toppings on this pizza are "<< m_topping1 << " " << m_topping2 << " " << m_topping3 << endl;
- }
- float specialtyPizza::computePrice() //New price computation
- {
- float price=0;
- if(m_size == "small")
- {
- price = 10;
- if(m_type == "deep dish") price += 2;
- if(m_type == "pan") price +=3;
- if(m_topping1 != "") price +=3;
- if(m_topping2 != "") price +=3;
- if(m_topping3 != "") price +=3;
- }
- else
- if(m_size == "medium")
- {
- price = 14;
- if(m_type == "deep dish") price += 4;
- if(m_type == "pan") price += 5;
- if(m_topping1 != "") price +=3;
- if(m_topping2 != "") price +=3;
- if(m_topping3 != "") price +=3;
- }
- else
- if(m_size == "large")
- {
- price = 17;
- if(m_type == "deep dish" || m_type == "pan") price +=6;
- if(m_topping1 != "") price +=3;
- if(m_topping2 != "") price +=3;
- if(m_topping3 != "") price +=3;
- }
- return price;
- }
Add Comment
Please, Sign In to add comment