Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "pizza.h"
- using namespace std;
- //========================
- // Pizza
- // The constructor sets the default pizza
- // to a small, deep dish, with only cheese.
- //========================
- Pizza::Pizza()
- {
- // Fill (1)-a
- }
- //==================================
- // Accessors and Mutators Follow
- //==================================
- // --------------------------------
- // ----- ENTER YOUR CODE HERE -----
- // --------------------------------
- int Pizza::getPepperoniToppings()
- {
- // Fill (1)-b
- }
- void Pizza::setPepperoniToppings(int numPepperoni)
- {
- // Fill (1)-c
- }
- int Pizza::getCheeseToppings()
- {
- // Fill (1)-d
- }
- void Pizza::setCheeseToppings(int numCheese)
- {
- // Fill (1)-e
- }
- int Pizza::getSize()
- {
- // Fill (1)-f
- }
- void Pizza::setSize(int newSize)
- {
- // Fill (1)-g
- }
- int Pizza::getType()
- {
- // Fill (1)-h
- }
- void Pizza::setType(int newType)
- {
- // Fill (1)-i
- }
- //==================================
- // outputDescription
- // Prints a textual description of the contents of the pizza.
- //==================================
- void Pizza::outputDescription()
- {
- cout << "This pizza is: ";
- switch (size)
- {
- case SMALL: cout << "Small, ";
- break;
- case MEDIUM: cout << "Medium, ";
- break;
- case LARGE: cout << "Large, ";
- break;
- default: cout << "Unknown size, ";
- }
- switch (type)
- {
- case DEEPDISH: cout << "Deep dish, ";
- break;
- case HANDTOSSED: cout << "Hand tossed, ";
- break;
- case PAN: cout << "Pan, ";
- break;
- default: cout << "Uknown type, ";
- }
- cout << "with " << pepperoniToppings << " pepperoni toppings " <<
- "and " << cheeseToppings << " cheese toppings." << endl;
- }
- //==================================
- // computePrice
- // Returns:
- // Price of a pizza using the formula:
- // Small = $10 + $2 per topping
- // Medium = $14 + $2 per topping
- // Large = $17 + $2 per topping
- //==================================
- double Pizza::computePrice()
- {
- double price = 0;
- switch (size)
- {
- case SMALL: price = 10; break;
- case MEDIUM: price = 14; break;
- case LARGE: price = 17; break;
- default: cout << "Error, invalid size." << endl;
- return -1;
- }
- price += (pepperoniToppings + cheeseToppings) * 2;
- return price;
- }
- // --------------------------------
- // --------- END USER CODE --------
- // --------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement