Question

USE!! PYTHON!!! Programming:   Pizza 1. Write a Pizza class to that this client code works. Please...

USE!! PYTHON!!!

Programming:   Pizza

1. Write a Pizza class to that this client code works. Please note that it is ok if the toppings are listed in a different order.

>>> pie = Pizza()

>>> pie

Pizza('M',set())

>>> pie.setSize('L')

>>> pie.getSize()

'L'

>>>pie.addTopping('pepperoni')

>>>pie.addTopping('anchovies')

>>>pie.addTopping('mushrooms')

>>> pie

Pizza('L',{'anchovies', 'mushrooms', 'pepperoni'})

>>>pie.addTopping('pepperoni')

>>> pie

Pizza('L',{'anchovies', 'mushrooms', 'pepperoni'})

>>>pie.removeTopping('anchovies')

>>> pie

Pizza('L',{'mushrooms', 'pepperoni'})

>>> pie.price()

16.65

>>> pie2 = Pizza('L',{'mushrooms','pepperoni'})

>>> pie2

Pizza('L',{'mushrooms', 'pepperoni'})

>>> pie==pie2

True

The Pizza class should have two attributes(data items):

size – a single character str, one of ‘S’,’M’,L”

toppings – a set containing the toppings. If you don’t remember how to use a set, make sure you look it up in the book. Please note that toppings may be listed in a different order, but hw2TEST.py takes that into account.

The Pizza class should have the following methods/operators):

__init__ - constructs a Pizza of a given size (defaults to ‘M’) and with a given set of toppings (defaults to empty set).    I highly recommend you look at the Queue class in the book to see how to get this to work correctly.

setSize – set pizza size to one of ‘S’,’M’or ‘L’

getSize – returns size

addTopping – adds a topping to the pizza, no duplicates, i.e., adding ‘pepperoni’ twice only adds it once

removeTopping – removes a topping from the pizza

price – returns the price of the pizza according to the following scheme:

‘S’: $6.25 plus 70 cents per topping
‘M’: $9.95 plus $1.45 per topping
‘L’: $12.95 plus $1.85 per topping

__repr__ - returns representation as a string – see output sample above. Note that toppings may be listed in a different order.

__eq__ - two pizzas are equal if they have the same size and same toppings (toppings don’t need to be in the same order)

2. Write a function orderPizza that allows the user input to build a pizza. It then prints a thank you message, the cost of the pizza and then returns the Pizza that was built.

>>> orderPizza()

Welcome to Python Pizza!

What size pizza would you like (S,M,L): M

Type topping to add (or Enter to quit): mushroom

Type topping to add (or Enter to quit): onion

Type topping to add (or Enter to quit): garlic

Type topping to add (or Enter to quit):

Thanks for ordering!

Your pizza costs $14.299999999999999

Pizza('M',{'mushroom', 'onion', 'garlic'})

>>> orderPizza()

Welcome to Python Pizza!

What size pizza would you like (S,M,L): L

Type topping to add (or Enter to quit): calamari

Type topping to add (or Enter to quit): garlic

Type topping to add (or Enter to quit):

Thanks for ordering!

Your pizza costs $16.65

Pizza('L',{'garlic', 'calamari'})

>>> p=orderPizza()

Welcome to Python Pizza!

What size pizza would you like (S,M,L): S

Type topping to add (or Enter to quit):

Thanks for ordering!

Your pizza costs $6.25

>>> p

Pizza('S',set())

>>>

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
USE!! PYTHON!!! Programming:   Pizza 1. Write a Pizza class to that this client code works. Please...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Python 3+ Adjust the following code so the two errors below are non-present: 1. __init__() :...

    Python 3+ Adjust the following code so the two errors below are non-present: 1. __init__() : Since Pizza object don't have it's own set() datastructure, the toppings in the pizza object are manimupated from out of the object. (-1.0) 2. __eq__() : How about "self.toppings == other.toppings" rather than "self.toppings - other.toppin == set())". Code: ## Program 1 ## --------------------------------- class Pizza: def __init__(self, s='M', top=set()): self.setSize(s) self.toppings = top def setSize(self, s): self.size = s def getSize(self): return self.size...

  • Take the Pizza class from assignment # 1 and modify it in the following way: -...

    Take the Pizza class from assignment # 1 and modify it in the following way: - Rename it to DeluxePizza. - Add a stuffedWithCheese (boolean) attribute to the class. - Add a veggie Topping (integer) attribute to the class. This attribute keeps track of the number of vegetables toppings excluding mushrooms. Add a static attribute numberOfPizzas (integer) which will keep track of the number of DeluxePizza objects created Update the existing non-default constructor such that it increments the numberOfPizzas by...

  • C# Programming Exercise and Bonus Exercise (Next Page) 1) Define a class called OrderPizza that has...

    C# Programming Exercise and Bonus Exercise (Next Page) 1) Define a class called OrderPizza that has member variables to track the type of pizza being order (either deep dish, hand tossed, or pan) along with the size (small, medium or large), type of toppings (pepperoni, cheese etc.) and the number of toppings. Create accessors for each property (ex.: type, size, type of toppings, and number of toppings). Implementation class should have a CalculateOrderPayment method to compute the total cost of...

  • Hello can someone help me in my code I left it as comment  task #0, task#1, task#2a...

    Hello can someone help me in my code I left it as comment  task #0, task#1, task#2a and task#2b the things that I am missing I'm using java domain class public class Pizza { private String pizzaCustomerName; private int pizzaSize; // 10, 12, 14, or 16 inches in diameter private char handThinDeep; // 'H' or 'T' or 'D' for hand tossed, thin crust, or deep dish, respecitively private boolean cheeseTopping; private boolean pepperoniTopping; private boolean sausageTopping; private boolean onionTopping; private boolean...

  • 1. Write a python script that will compute and display information for a company which rents...

    1. Write a python script that will compute and display information for a company which rents vehicles to its customers. For a specified customer, the program will compute and display the amount of money charged for that customer’s vehicle rental after prompting the user to enter the following four items for a given customer (in the specified order)  The car type (a character either C (compact), M (mid-size), L (luxury), S (SUV), or V (Van) )  The number...

  • The attached document is a C++ source code, INTERFACE__Class{aSet}.cpp, which contains an interface for class aSet and an implementation section which is largely left empty, so that students could fill in the missing code, where it is written // C++ code

    /* FILE NAME: Class{aSet}.cpp FUNCTION: A template class for a set in C++. It implements all the set operations, except set compliment:  For any two sets, S1 and S2 and an element, e  A. Operations which result in a new set:  (1) S1 + S2 is the union of S1 and S2 (2) S1 - S2 is the set difference of S1 and S2, S1 - S2 (3) S1 * S2 is the set intersection of S1 and S2, S1 * S2 (4) S1 + e (or e +...

  • Use python write Thank you so much! pets.txt dog alyson 5.5 cat chester 1.5 cat felice...

    Use python write Thank you so much! pets.txt dog alyson 5.5 cat chester 1.5 cat felice 16 dog jesse 14 cat merlin 5 cat percy 12 cat puppet 18 to_transfer.txt cat merlin 5 cat percy 12 intake.txt bird joe 3 cat sylvester 4.5 the website is https://www2.cs.arizona.edu/classes/cs110/spring17/homework.shtml Welcome to animal shelter management software version 1.0 Type one of the following options adopt a pet adopt intake add more animals to the shelter list. display all adoptable pets quit exit the...

  • Python only please, thanks in advance. Type up the GeometricObject class (code given on the back...

    Python only please, thanks in advance. Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...

  • Please help as it is very important task for me please write in Python code and...

    Please help as it is very important task for me please write in Python code and divide this into function and write comments for it 1. Ask the player’s name and welcome them to the game using their name. 2. Ask the player what is par for this game (number between 3-5 inclusive) 3. Ask the player what the distance to the hole for this game is (whole number between 195 and 250 inclusive) 4. Show the game menu: (I)nstructions...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT