SHARE
TWEET

Untitled

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