Completed 9-10 Imported Restaurant
This commit is contained in:
parent
bff068901a
commit
cf2141779b
8
Chapter_09/9-10_imported_restaurant.py
Normal file
8
Chapter_09/9-10_imported_restaurant.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Exercise 9-10 Imported Restaurant
|
||||||
|
# Learning Objective: Separate, import, and use a class
|
||||||
|
|
||||||
|
from restaurant import Restaurant
|
||||||
|
|
||||||
|
tonys_pizza = Restaurant("Tony's Pizza", "Pizzeria")
|
||||||
|
|
||||||
|
tonys_pizza.describe_restaurant()
|
||||||
14
Chapter_09/restaurant.py
Normal file
14
Chapter_09/restaurant.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
class Restaurant:
|
||||||
|
def __init__(self, name, cuisine_type):
|
||||||
|
"""Initialize variables name and cuisine_type, define functions to describe and to open restaurant..."""
|
||||||
|
|
||||||
|
self.name = name
|
||||||
|
self.cuisine_type = cuisine_type
|
||||||
|
|
||||||
|
def describe_restaurant(self):
|
||||||
|
"""Describe the restaurant"""
|
||||||
|
print(f"The restaurant's name is {self.name} and the cuisine served here is {self.cuisine_type}")
|
||||||
|
|
||||||
|
def open_restaurant(self):
|
||||||
|
"""Simulate it being opened"""
|
||||||
|
print(f"{self.name} is now open for business.")
|
||||||
Loading…
x
Reference in New Issue
Block a user