Guest User

Untitled

a guest
Sep 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. //Adeeb Khadem
  2. //3-25-2012
  3. //Creates specialty pizza classes, then tests them
  4.  
  5. #include <iostream>
  6. #include "Pizza.h"
  7. using namespace std;
  8.  
  9. class specialtyPizza: public Pizza{ //Create class
  10.  
  11. private:
  12. string m_topping1;
  13. string m_topping2;
  14. string m_topping3;
  15. public:
  16. void setTopping1(string);
  17. string getTopping1();
  18. void setTopping2(string);
  19. string getTopping2();
  20. void setTopping3(string);
  21. string getTopping3();
  22. void DisplayToppings();
  23. void Display();
  24. float computePrice();
  25. specialtyPizza();
  26. specialtyPizza(string, string, string, string, string);
  27. };
  28. specialtyPizza::specialtyPizza() //Define methods
  29. {
  30. m_size = "small";
  31. m_type = "hand tossed";
  32. m_topping1 = "";
  33. m_topping2 = "";
  34. m_topping3 = "";
  35. }
  36.  
  37. specialtyPizza::specialtyPizza(string size, string type, string topping1a, string topping2a, string topping3a) //Define methods
  38. {
  39. m_size = size;
  40. m_type = type;
  41. m_topping1 = topping1a;
  42. m_topping2 = topping2a;
  43. m_topping3 = topping3a;
  44. }
  45. void specialtyPizza::setTopping1(string topping1) //Topping variables
  46. {
  47. m_topping1 = topping1;
  48. }
  49. void specialtyPizza::setTopping2(string topping2)
  50. {
  51. m_topping2 = topping2;
  52. }
  53. void specialtyPizza::setTopping3(string topping3)
  54. {
  55. m_topping3 = topping3;
  56. }
  57. void specialtyPizza::Display()
  58. {
  59. cout << m_size << " " << m_type << " " << m_topping1 << " " << m_topping2 << " " << m_topping3 << " $" << computePrice() << endl;
  60. }
  61. void specialtyPizza::DisplayToppings()
  62. {
  63. cout << "The toppings on this pizza are "<< m_topping1 << " " << m_topping2 << " " << m_topping3 << endl;
  64. }
  65. float specialtyPizza::computePrice() //New price computation
  66. {
  67. float price=0;
  68. if(m_size == "small")
  69. {
  70. price = 10;
  71. if(m_type == "deep dish") price += 2;
  72. if(m_type == "pan") price +=3;
  73. if(m_topping1 != "") price +=3;
  74. if(m_topping2 != "") price +=3;
  75. if(m_topping3 != "") price +=3;
  76. }
  77. else
  78. if(m_size == "medium")
  79. {
  80. price = 14;
  81. if(m_type == "deep dish") price += 4;
  82. if(m_type == "pan") price += 5;
  83. if(m_topping1 != "") price +=3;
  84. if(m_topping2 != "") price +=3;
  85. if(m_topping3 != "") price +=3;
  86. }
  87. else
  88. if(m_size == "large")
  89. {
  90. price = 17;
  91. if(m_type == "deep dish" || m_type == "pan") price +=6;
  92. if(m_topping1 != "") price +=3;
  93. if(m_topping2 != "") price +=3;
  94. if(m_topping3 != "") price +=3;
  95. }
  96. return price;
  97. }
Add Comment
Please, Sign In to add comment