Advertisement
Guest User

Pizza pizza.cpp

a guest
Apr 21st, 2019
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. #include <iostream>
  2. #include "pizza.h"
  3.  
  4. using namespace std;
  5.  
  6. //========================
  7. // Pizza
  8. // The constructor sets the default pizza
  9. // to a small, deep dish, with only cheese.
  10. //========================
  11. Pizza::Pizza()
  12. {
  13. // Fill (1)-a
  14. }
  15.  
  16.  
  17. //==================================
  18. // Accessors and Mutators Follow
  19. //==================================
  20.  
  21. // --------------------------------
  22. // ----- ENTER YOUR CODE HERE -----
  23. // --------------------------------
  24.  
  25. int Pizza::getPepperoniToppings()
  26. {
  27. // Fill (1)-b
  28. }
  29.  
  30. void Pizza::setPepperoniToppings(int numPepperoni)
  31. {
  32. // Fill (1)-c
  33. }
  34.  
  35. int Pizza::getCheeseToppings()
  36. {
  37. // Fill (1)-d
  38. }
  39.  
  40. void Pizza::setCheeseToppings(int numCheese)
  41. {
  42. // Fill (1)-e
  43. }
  44.  
  45. int Pizza::getSize()
  46. {
  47. // Fill (1)-f
  48. }
  49.  
  50. void Pizza::setSize(int newSize)
  51. {
  52. // Fill (1)-g
  53. }
  54.  
  55. int Pizza::getType()
  56. {
  57. // Fill (1)-h
  58. }
  59.  
  60. void Pizza::setType(int newType)
  61. {
  62. // Fill (1)-i
  63. }
  64.  
  65. //==================================
  66. // outputDescription
  67. // Prints a textual description of the contents of the pizza.
  68. //==================================
  69. void Pizza::outputDescription()
  70. {
  71. cout << "This pizza is: ";
  72. switch (size)
  73. {
  74. case SMALL: cout << "Small, ";
  75. break;
  76. case MEDIUM: cout << "Medium, ";
  77. break;
  78. case LARGE: cout << "Large, ";
  79. break;
  80. default: cout << "Unknown size, ";
  81. }
  82. switch (type)
  83. {
  84. case DEEPDISH: cout << "Deep dish, ";
  85. break;
  86. case HANDTOSSED: cout << "Hand tossed, ";
  87. break;
  88. case PAN: cout << "Pan, ";
  89. break;
  90. default: cout << "Uknown type, ";
  91. }
  92. cout << "with " << pepperoniToppings << " pepperoni toppings " <<
  93. "and " << cheeseToppings << " cheese toppings." << endl;
  94. }
  95.  
  96. //==================================
  97. // computePrice
  98. // Returns:
  99. // Price of a pizza using the formula:
  100. // Small = $10 + $2 per topping
  101. // Medium = $14 + $2 per topping
  102. // Large = $17 + $2 per topping
  103. //==================================
  104. double Pizza::computePrice()
  105. {
  106. double price = 0;
  107. switch (size)
  108. {
  109. case SMALL: price = 10; break;
  110. case MEDIUM: price = 14; break;
  111. case LARGE: price = 17; break;
  112. default: cout << "Error, invalid size." << endl;
  113. return -1;
  114. }
  115. price += (pepperoniToppings + cheeseToppings) * 2;
  116. return price;
  117. }
  118.  
  119. // --------------------------------
  120. // --------- END USER CODE --------
  121. // --------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement