python homework

class Restaurant(object):
    def __init__(self, restaurant_name, cuisine_type):
        self.restaurant_name = restaurant_name
        self.cuisine_type = cuisine_type
        self.number_served = 0

    def describe_restaurant(self):
        print("Restaurant_name: %s, cuisine_type: %s" % (self.restaurant_name, self.cuisine_type))

    def open_restaurant(self):
        print("Restaurant is opening!")

    def set_number_served(self, number):
        self.number_served = number

    def increment_number_served(self, max_number):
        if self.number_served >= max_number:
            print("Limit reached!!")
        else:
            self.number_served += 1


class IceCreamStand(Restaurant):
    def __init__(self, restaurant_name, cuisine_type, flavors):
        super().__init__(restaurant_name, cuisine_type)
        self.flavors = flavors

    def show_flavors(self):
        print("flavors: " + str(self.flavors))
class User(object):
    def __init__(self, first_name, last_name, favorite):
        self.first_name = first_name
        self.last_name = last_name
        self.favorite = favorite
        self.login_attempts = 0

    def describe_user(self):
        print("User name: %s" % (self.first_name + " " + self.last_name))

    def greet_user(self):
        print("Hello %s, welcome!" % (self.first_name + " " + self.last_name))

    def increment_login_attempts(self):
        self.login_attempts += 1

    def reset_login_attempts(self):
        self.login_attempts = 0


class Admin(User):
    def __init__(self, first_name, last_name, favorite, privileges):
        super().__init__(first_name, last_name, favorite)
        self.privileges = privileges

    def show_privileges(self):
        print("user has privileges" + self.privileges)
```


```python
from rest.Restaurant import *
from rest.User import *


restaurant = Restaurant("HX", "chinese")
restaurant.describe_restaurant()
restaurant.open_restaurant()

user = User("Liujian", "Zhou", "")
user.greet_user()
user.describe_user()
user.increment_login_attempts()
user.increment_login_attempts()
user.increment_login_attempts()
print(user.login_attempts)
user.reset_login_attempts()
print(user.login_attempts)

admin = Admin("xin", "Hu", "", "can add/delete/remove")
admin.show_privileges()
```

你可能感兴趣的:(python,开发语言)