Я делаю некоторые функции, которые я не знаю, как их сделать
Я пробовал некоторые функции, и они предоставляются
class TopChefException(Exception):
pass
Структура для шеф-повара
Я не понимаю оба этих класса, этот дан, и мы должны сделать следующий.
class Chef:
def __init__(self, chef_id=None, chef_name=None, chef_restaurant=None):
self.id = chef_id
self.name = chef_name
self.restaurant = chef_restaurant
self.score = 0.0
def get_id(self):
return self.id
def add_score(self, score):
self.score += score
def get_name(self):
return self.name
def get_restaurant(self):
return self.restaurant
def get_score(self):
return self.score
def set_score(self, score):
self.score = score
def __str__(self):
chef_str = "ID: %s; " % (str(self.id))
chef_str += "NAME: %s; " % (self.name)
chef_str += "RESTAURANT: %s; " % (self.restaurant)
chef_str += "SCORE: %s" % (self.score)
return chef_str
Структура для размещения всех поваров
Этот класс похож, но он нам дан, и я хочу знать, связан ли он со списком или мы можем сделать что-то еще.
class Chefs:
def __init__(self):
self.chefs = {}
self.next = 0
self.sorted_chefs = []
def exists(self, id):
# Complete this function
return False
def get_ids(self):
# Complete this function
return None
def add_chef(self, name, restaurant):
# Complete this function
return None
def get_chef(self, id):
# Complete this function
return None
def is_sorted(self):
# Complete this function
return False
def sort_chefs(self):
# Complete this function
pass
def get_top_n(self, n=1):
# Complete this function
return None
def __str__(self):
# Complete this function
chefs_str = ""
return chefs_str
def __len__(self):
# Complete this function
return None