From c72b7d015fea4d42dcae0a378293dffb391844fc Mon Sep 17 00:00:00 2001 From: cheeks <134818917+leftovertoast@users.noreply.github.com> Date: Thu, 27 Feb 2025 23:51:45 +0000 Subject: [PATCH] Completed Exercise 9-1 Restuarant --- Chapter_09/9-01_restaurant.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Chapter_09/9-01_restaurant.py diff --git a/Chapter_09/9-01_restaurant.py b/Chapter_09/9-01_restaurant.py new file mode 100644 index 0000000..59dbf2f --- /dev/null +++ b/Chapter_09/9-01_restaurant.py @@ -0,0 +1,23 @@ +# Exercise 9-1 Restaurant +# Learning Objective: Create a class in python that accepts two parameters and has one method other than self. + +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.") + +my_restaurant = Restaurant("Pete's Perturbed Petunias", "Somalian Greek Fusion") +print(f"{my_restaurant.name}") +print(f"{my_restaurant.cuisine_type}") +my_restaurant.describe_restaurant() +my_restaurant.open_restaurant()