Answer to Question #290162 in Python for dv13

Question #290162

1. Create a class Restaurant, the __init__ (self, Name, Country, City, BranchNumber, CuisineType) method for restaurant should store restaurant name, country, city, its branch number and cuisine type.


2. Create a method DescRestaurant that prints the name, Country, City, BranchNumber and Cuisine type of the restaurant.


3. Create a method RestaurantTiming, the method should print out the opening and closing time of the restaurant.


4. Create two instances of the class Restaurant with two different Names, Country, City, BranchNumber and CuisineType then call the DescRestaurant and RestaurantTiming method for each instance. 


1
Expert's answer
2022-01-24T08:03:57-0500
import time


class Restaurant:
    def __init__(self, Name, Country, City, BranchNumber, CuisinType):
        self._name = Name
        self._country = Country
        self._city = City
        self._branch_number = BranchNumber
        self._cuisin_type = CuisinType
        self._openning = time.strptime("11:00:00", "%H:%M:%S")
        #self._openning = time.struct_time(tm_hour=11, tm_min=0, tm_sec=0)
        self._closing = time.strptime("00:00:00", "%H:%M:%S")
        #self._closing = time.struct_time(tm_hour=23, tm_min=0, tm_sec=0)


    def DescRestaurant(self):
        print("Name:", self._name)
        print("Country:", self._country)
        print("Branch number:", self._branch_number)
        print("Cuisine type:", self._cuisin_type)
    
    def RestaurantTiming(self):
        s = time.strftime("%H:%M", self._openning)
        print("Openning:", s)
        s = time.strftime("%H:%M", self._closing)
        print("Closing:", s)


def main():
    resto1 = Restaurant("Noma", "Denmark", "Copenhagen", 123, "New Nordic")
    resto2 = Restaurant("Asado Etxebari", "Spain", "Atxondo", 987, "Local cuisine")


    print("The best restaurant:")
    resto1.DescRestaurant()
    resto1.RestaurantTiming()


    print("\nMy second favorite restaurant:")
    resto2.DescRestaurant()
    resto2.RestaurantTiming()


if __name__ == '__main__':
    main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS