Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.89 KB | None | 0 0
  1. """
  2. This is the Restaurant class
  3.  
  4. 9-1. Restaurant: Make a class called Restaurant. The __init__() method for
  5. Restaurant should store two attributes: a restaurant_name and a cuisine_type.
  6. Make a method called describe_restaurant() that prints these two pieces of
  7. information, and a method called open_restaurant() that prints a message indicating
  8. that the restaurant is open.
  9.  
  10. Add a method called set_number_served() that lets you set the number
  11. of customers that have been served.
  12.  
  13. Add a method called increment_number_served() that lets you increment
  14. the number of customers who’ve been served.
  15. """
  16.  
  17. class Restaurant():
  18.     def __init__(self, name, cuisine_type, number_served=0):
  19.         self.name = name
  20.         self.cuisine_type = cuisine_type
  21.         self.number_serverd = number_served
  22.  
  23.     def descripe_restaurant(self):
  24.         print("The restaurant name is "+ self.name.capitalize() +".")
  25.         print("The cuisine that this restaurant serves is "+ self.cuisine_type.title() +".")
  26.  
  27.     def open_restaurant(self):
  28.         print("The restaurant is now open")
  29.  
  30.     def set_number_served(self, number_served):
  31.         self.number_serverd = number_served
  32.  
  33.     def increment_number_served(self, number):
  34.         self.number_serverd += number
  35.  
  36.  
  37. """
  38. Ice Cream Stand: An ice cream stand is a specific kind of restaurant. Write
  39. a class called IceCreamStand that inherits from the Restaurant class you wrote
  40. in Exercise 9-1 (page 166) or Exercise 9-4 (page 171). Either version of
  41. the class will work; just pick the one you like better. Add an attribute called
  42. flavors that stores a list of ice cream flavors. Write a method that displays
  43. these flavors.
  44. """
  45.  
  46. class IceCreamStand(Restaurant):
  47.  
  48.     def __init(self, name, *flavors):
  49.         super.__init__(name)
  50.         self.flavors = []
  51.  
  52.     def displaying_flavors(self):
  53.         for flavor in self.flavors:
  54.             print(flavor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement