def restart(): global game,plusBox,tus,control,human,dog,stopTime game.score = 0 plusBox = PlusBox() tus = Tus() control = Control() human = Human() dog = Dog() stopTime = 2.0
def main(self): WillieWolf = Wolf(FeedWithFear) WhinnyWolf = Wolf(FeedWithFear) CarlCat = Cat() CindyCat = Cat() DougDog = Dog(FeedWithCare) DippyDog = Dog(FeedWithCare) EllyElephant = Elephant() EarlElephant = Elephant() HarryHippo = Hippo() HenryHippo = Hippo() LillyLion = Lion() LarryLion = Lion() RyanRhino = Rhino() RandyRhino = Rhino() TonyTiger = Tiger() TimmyTiger = Tiger() ZaneZooKeeper = ZooKeeper() ZaneZooKeeper.Add(WillieWolf) ZaneZooKeeper.Add(WhinnyWolf) ZaneZooKeeper.Add(CarlCat) ZaneZooKeeper.Add(CindyCat) ZaneZooKeeper.Add(DougDog) ZaneZooKeeper.Add(DippyDog) ZaneZooKeeper.Add(EllyElephant) ZaneZooKeeper.Add(EarlElephant) ZaneZooKeeper.Add(HarryHippo) ZaneZooKeeper.Add(HenryHippo) ZaneZooKeeper.Add(LillyLion) ZaneZooKeeper.Add(LarryLion) ZaneZooKeeper.Add(RyanRhino) ZaneZooKeeper.Add(RandyRhino) ZaneZooKeeper.Add(TonyTiger) ZaneZooKeeper.Add(TimmyTiger) ZaneZooKeeper.WakeUp() ZaneZooKeeper.RollCall() ZaneZooKeeper.Roam() ZaneZooKeeper.Eat() ZaneZooKeeper.Sleep()
def setup(self): """ Setup the game (or reset the game) """ self.view_bottom = 0 self.view_left = 0 self.score = 0 arcade.set_background_color(BACKGROUND_COLOR) self.dog_list = arcade.SpriteList() self.wall_list = arcade.SpriteList() self.candy_list = arcade.SpriteList() self.dog_sprite = Dog("images/dog.png", scale=2) self.dog_sprite.center_x = 250 self.dog_list.append(self.dog_sprite) # Creating the ground for x in range(-1000, 50000, 64): wall = arcade.Sprite("images/fire.png", scale=0.5) wall.center_x = x wall.center_y = 32 self.wall_list.append(wall) coordinate_list = [[250, 175], [random.randint(300, 10000), random.randint(150, 450)], [random.randint(300, 10000), random.randint(150, 450)], [random.randint(300, 10000), random.randint(150, 450)]] x = 0 while x < 100: coordinate_list.append([random.randint(500, 10000), random.randint(150, 450)]) x += 1 for coordinate in coordinate_list: crate = arcade.Sprite("images/RTS_Crate.png", TILE_SCALING) crate.position = coordinate self.wall_list.append(crate) for x in range(10000): candy = arcade.Sprite("images/eyecandy_1.png", CANDY_SCALING) candy.center_x = random.randrange(150, 10000) candy.center_y = random.randrange(150, 10000) self.candy_list.append(candy) self.physics_engine = arcade.PhysicsEnginePlatformer(self.dog_sprite, self.wall_list, GRAVITY)
def post(self): db = db_handler.DbHandler() db.connectDb() dog = Dog.Dog() # creating a Dog object # Setting the Dog object attributes from user input dog.owner_email = users.get_current_user() dog.dog_id = self.request.get('id') dog.dog_name = self.request.get('name') dog.dog_age = self.request.get('age') dog.dog_gender = self.request.get('gender') dog.breed_name = self.request.get('breed') if db.exists(dog.dog_id, "Dog_ID", "Dog"): # validates that dog is doesn't exist in the DB # if it exists, renders the same page again with the message Dog ID must be unique template = jinja_environment.get_template('dog_register.html') parameters_for_template = {"id": " Dog ID must be unique!"} self.response.out.write(template.render(parameters_for_template)) db.disconnectDb() return dog.insertToDB() # Inserting Dog to DB template = jinja_environment.get_template('home_or_another_dog.html') self.response.out.write(template.render())
import Dog from Dog miles = Dog("Miles", 4) print(miles.description())
clock = pygame.time.Clock() sheepImage = pygame.image.load('sheep.png') dogImage = pygame.image.load('dog.png') worldBounds = Vector(WORLD_WIDTH, WORLD_HEIGHT) # Setup the graph graph = Graph() # Setup the gates and obstacles penBounds = buildGates(graph) buildObstacles(graph) atEntrance = [] # Setup the dog dog = Dog(dogImage, Vector(WORLD_WIDTH * .5, WORLD_HEIGHT * .5), Vector(DOG_WIDTH, DOG_HEIGHT), (0, 255, 0), DOG_SPEED, DOG_ANGULAR_SPEED) # Setup the sheep (only 1 for now...) herd = [] while len(herd) < Constants.SHEEP_COUNT: sheep = Sheep( sheepImage, Vector(randrange(int(worldBounds.x * .05), int(worldBounds.x * .95)), randrange(int(worldBounds.y * .05), int(worldBounds.y * .95))), Vector(DOG_WIDTH, DOG_HEIGHT), (0, 255, 0), SHEEP_SPEED, SHEEP_ANGULAR_SPEED) if not (sheep.boundingRect.colliderect(penBounds[0]) or sheep.boundingRect.colliderect(penBounds[1])): herd.append(sheep)
import Animal import Dog myAnimal = Animal.animal() myAnimal.run() # myDog = Animal.dog('Dong') # myDog.show() myDog = Dog.dog('Dong') myDog.show()
class Zoo: def __init__(self, zoo_name): self.zoo_name = zoo_name self.animals = {} def add_new_animal_by_id(self, animal): animal_id = id(animal) if animal_id in self.animals: raise ValueError(f"Animal {animal.__dict__['name']} already in the zoo!") from BaseException self.animals[animal_id] = animal def get_all_animals(self): for v in self.animals.values(): print(v.__dict__) def has_animal(self, animal_name): for v in self.animals.values(): if v.__dict__['name'] == animal_name: print(f'{animal_name} is in the zoo') if __name__ == '__main__': cat1 = Cat.Cat('cat1', 'meat', 'medium', 'dangerous') cat2 = Cat.Cat('cat2', 'meat', 'small', 'dangerous') dog1 = Dog.Dog('dog1', 'meat', 'medium', 'dangerous') zoo1 = Zoo('Zoo1') zoo1.add_new_animal_by_id(cat1) zoo1.add_new_animal_by_id(cat2) zoo1.add_new_animal_by_id(cat1) zoo1.has_animal('cat1')
In the constructor set lives left to live to `1`. Dont forget to import the new class. Initiate a new variable called `dog` with the *Dog class*, give dog the name "Lilly" and eye color "blue". Put cat and dog variables in a list. Iterate through the list and put their descriptions together in a string without any seperation between the two. Answer with the string. Write your code below and put the answer into the variable ANSWER. """ dog = Dog.Dog("blue", "Lilly") list_dogsAndCats = [cat, dog] str_result = "" for obj in list_dogsAndCats: str_result += obj.description() ANSWER = str_result # I will now test your answer - change false to true to get a hint. print(dbwebb.assertEqual("1.4", ANSWER, False)) """ Exercise 1.5 Create a private variable for the Cat class called `evil`.
#my_dogs.py import Dog my_dog = Dog.Dog("Rex", "SuperDog") my_dog.bark() my_other_dog = Dog.Dog("Annie", "SuperDog")
''' Created on 2017年6月7日 @author: Administrator ''' from Dog import * my_dog = Dog('willie', 6) print("My dog's name is " + my_dog.name.title() + ".") my_dog.roll_over() my_restaurant = Restaurant('上岛咖啡馆', '知名咖啡馆,休闲娱乐的地方') my_restaurant.describe_restaurant() my_restaurant.open_restaurant() my_car = Car('bmw', 'x6', '2016') ben_car = Car('Benchi', 'a8', '2017') desc = my_car.car_descrption() print(desc) my_car.car_start() my_car.car_stop() my_car.read_odometer() my_car.update_odometer(100) my_car.update_odometer(100) ben_car.read_odometer() my_car.fill_gas_tank() elec_car = ElectricCar('dazhong', 'toyota', '2017', 10) elecar = elec_car.car_descrption() print(elecar) elec_car.charge_electric(4) elec_car.battery.describe_battery()
import Dog my_dog = Dog.Dog("Rex", "SuperDog") my_dog.bark() my_other_dog = Dog.Dog("Annie", "SuperDog") print(my_other_dog.name) french_bulldog = Dog.Dog("Jacque", "French Bulldog") french_bulldog.bark = "Arrrff" print(french_bulldog.name) print(french_bulldog.breed) print(french_bulldog.bark) french_mastif = Dog.Dog("Claude", "French Mastif") french_mastif.bark = "Rrruuf" print(french_mastif.name) print(french_mastif.breed) print(french_mastif.bark) brussells_griffon = Dog.Dog("Celine", "Brussels Griffon") brussells_griffon.bark = "aaff" print(brussells_griffon.name) print(brussells_griffon.breed) print(brussells_griffon.bark)
import Dog if __name__ == "__main__": bobby = Dog("bobby") bobby.bark() woolf = Dog("woolf") woolf.bark()
def __init__(self, level_size, kitties, dogs): pygame.init() pygame.font.init() pygame.mixer.init() pygame.mixer.music.load("data\\sounds\\rain.wav") pygame.mixer.music.play(-1) self.level_size = level_size self.kitties_n = kitties self.dogs_n = dogs self.fps = 20 self.size = (640, 480) self.screen = pygame.display.set_mode(self.size) self.loading_screen = pygame.Surface(self.size) self.loading_screen.fill((0, 0, 0)) self.screen.blit(self.loading_screen, (0, 0)) self.screen.blit( pygame.font.SysFont("comicsansms", 20).render("Loading", False, (255, 255, 255)), (self.size[0] / 2, self.size[1] / 2)) pygame.display.flip() self.level = Level.Level(self.level_size) self.level_size_p = self.level.level_size_p self.kitties = [] self.kitties_del = [] self.dogs = [] self.cat = Cat.Cat(self.level.safespace.center, self.level_size_p, self.kitties, self.kitties_del, self.dogs) for i in range(self.dogs_n): self.dogs.append(Dog.Dog(self.level_size_p, self.kitties, self.cat)) for i in range(self.kitties_n): self.kitties.append( Kitty.Kitty(self.level_size_p, self.level.safespace, self.cat)) self.pause = False self.draws = [self.level.safespace] + self.dogs + self.kitties self.updates = [self.cat] + self.kitties + self.dogs self.camera = Camera.Camera( ((self.level.level_size_p[0] - self.size[0]) / 2 - 1, self.level.level_size_p[1] - self.size[1] - 1), self.size, self.level, self.cat, self.kitties, self.draws, self.screen, self.level_size_p) self.keydown_handlers = defaultdict(list) self.keyup_handlers = defaultdict(list) self.keydown_handlers[pygame.K_UP].append(self.cat.act) self.keydown_handlers[pygame.K_RIGHT].append(self.cat.act) self.keydown_handlers[pygame.K_DOWN].append(self.cat.act) self.keydown_handlers[pygame.K_LEFT].append(self.cat.act) self.keydown_handlers[pygame.K_F1].append(self.camera.about_switch) self.keydown_handlers[pygame.K_c].append(self.cat.meow) self.keydown_handlers[pygame.K_x].append(self.cat.ask_meow) self.keydown_handlers[pygame.K_z].append(self.cat.hit) self.keydown_handlers[pygame.K_LSHIFT].append(self.cat.speedy) self.keyup_handlers[pygame.K_UP].append(self.cat.act) self.keyup_handlers[pygame.K_RIGHT].append(self.cat.act) self.keyup_handlers[pygame.K_DOWN].append(self.cat.act) self.keyup_handlers[pygame.K_LEFT].append(self.cat.act) self.keyup_handlers[pygame.K_LSHIFT].append(self.cat.act) self.keyup_handlers[pygame.K_F1].append(self.camera.about_switch) self.keyup_handlers[pygame.K_LSHIFT].append(self.cat.speedy) while len(self.kitties): self.start = time.time() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() elif event.type == pygame.KEYDOWN: for handler in self.keydown_handlers[event.key]: handler() elif event.type == pygame.KEYUP: for handler in self.keyup_handlers[event.key]: handler() for i in self.updates: i.update() if len(self.kitties_del): for i in self.kitties_del: if not i.state: self.kitties_del.remove(i) self.kitties.remove(i) self.draws.remove(i) self.updates.remove(i) self.camera.draw() pygame.display.flip() self.end = time.time() self.diff = self.end - self.start self.delay = 1.0 / self.fps - self.diff if self.delay > 0: time.sleep(self.delay) self.screen.blit( pygame.font.SysFont("comicsansms", 20).render("You win! Restarting…", False, (255, 255, 255)), (self.size[0] / 3, self.size[1] / 3)) pygame.display.flip() time.sleep(5)
#from Dog import Dog,Family,PetDog import Dog # ~ from Dog import * 不推荐 my_pet_dog = Dog.PetDog('my_pet_dog', 999) print(my_pet_dog.name) my_pet_dog.bark() my_pet_dog.food = ['a', 'b', 'c'] my_pet_dog.print_food() my_pet_dog.eat_bone() dad = my_pet_dog.family.get_dad() print(dad)
message='' message += "This car goes approx 90 miles /h" print(message) return range2 class ElectricCar(Dog.Car): def __init__(self, make, model, year=3): """Need a default parameter in the subclass constructor""" super().__init__(make, model, year) self.battery = Battery() def describe_battery(self): """Print a statement describing the battery size.""" print("This car has a " + str(self.battery.battery_size) + "-kWh battery. And life " "percent is " + str(self.battery.battery_lifepercent()) + " and the range is " + str(self.battery.range())) def inc_odometer(self, number): self.odometer += number*2 car = ElectricCar('da', 'das', 43) car.inc_odometer(2) car.odometer_reading() car.describe_battery() d = Dog.Dog('ads', 45) print(d.age) ds = Dog.Car('as', 'Bn') print(ds.get_descriptive_name())
# -*- coding: utf-8 -*- """ Created on Wed Nov 11 01:39:04 2020 @author: ucobiz """ from Dog import * #from Dog import Dog import Dog as dog_obj d = Dog("Fido") e = dog_obj.Dog("Buddy") d.add_tricks("roll over") e.add_tricks("play dead") print(d.tricks) print(e.tricks)
def main(): print("Starting main()\n") fido = Dog("Fido", 3) # Instantiates a new Dog object print("Hello, my name is " + fido.get_name()) print("I am " + str(fido.get_age()) + " years old.") print("I am " + str(fido.get_age_in_dog_years()) + " years old in dog years.\n") fido.bark() fido.wag_tail() print("") # Adds a new-line to output for readability print("Now it is my birthday.") fido.have_a_birthday() print("Now, I am " + str(fido.get_age()) + " years old.") print("And I am " + str(fido.get_age_in_dog_years()) + " years old in dog years.\n") print("Finished main()")
提示:注意组织代码的方式;狗类用一个单独的py文件; 人用一个单独的py文件; 在写一个fight模块(也用类来组织; 在这个模块中,导入人和狗模块中编写好的方法 ''' import People import Dog import random if __name__ == "__main__": print("游戏开始~~") print("\n") p0 = People.people(0) p1 = People.people(1) p = [p0, p1] d0 = Dog.dog(0) d1 = Dog.dog(1) d2 = Dog.dog(2) d = [d0, d1, d2] count = random.randint(0, 1) ##0狗咬人,1人打狗 while True: if count == 0 and len(p) > 0 and len(d) > 0: ##狗攻击人 num1 = random.randint(0, len(d) - 1) ##狗子 num2 = random.randint(0, len(p) - 1) ##人 print("小狗{}号咬了{}号人一口".format(d[num1].name, p[num2].name)) p[num2].be_attacked(d[num1].attack) print("{}号人,血量还剩{},攻击力还剩{}".format(p[num2].name, p[num2].blood, p[num2].attack)) if p[num2].blood <= 0: print("{}号人失血过度,离我们远去了~~~".format(p[num2].name))
#!/usr/bin/env python # -*- coding:utf-8 -*- # file:fight.py # author:74049 # datetime:2021/4/17 16:45 # software: PyCharm ''' this is functiondescription ''' # import module your need import Dog import People import random dog1 = Dog.Dog() dog2 = Dog.Dog() dog3 = Dog.Dog() people1 = People.People() people2 = People.People() list_dog = [dog1, dog2, dog3] list_people = [people1, people2] lis = [list_dog, list_people] while len(list_dog) != 0: if len(list_people) != 0: dog_num = random.randint(0, len(list_dog) - 1) people_num = random.randint(0, len(list_people) - 1)
# Also confirm that your Dog class can not fly(). import Animal animal1 = Animal.Animal( "myAnimal1" ) animal1.walk() animal1.walk() animal1.walk() animal1.run() animal1.run() animal1.displayHealth() # Confirm that the health attribute has changed. import Dog dog1 = Dog.Dog( "myDog1" ) dog1.walk() dog1.walk() dog1.walk() dog1.run() dog1.run() dog1.pet() dog1.displayHealth() try: dog1.fly() except Exception as e: print "Exception: Cannot use method .fly() on Dog instance!" import Dragon dragon1 = Dragon.Dragon( "myDragon1" )
import Tiger import Wolf import Dog import ZooKeeper import ZooAnnouncer if __name__ == '__main__': # Instantiating all the animals in the zoo. Chesire = Cat.Cat("Chesire") Calum = Cat.Cat("Calum") Timon = Tiger.Tiger("Timon") Tina = Tiger.Tiger("Tina") Walace = Wolf.Wolf("Walace") Willy = Wolf.Wolf("Willy") Diane = Dog.Dog("Diane") Dan = Dog.Dog("Dan") # Placing all the animals into a list animals = [Chesire, Calum, Timon, Tina, Walace, Willy, Diane, Dan] # Instantiating the Zoo Announcer, Zoo Keeper, Attaching the Announcer to get updates from # the Zoo Keeper, and having the Zoo Keeper go through their daily duties. Announcer = ZooAnnouncer.ZooAnnouncer() Keeper = ZooKeeper.ZooKeeper(animals) Keeper.attach(Announcer) Keeper.wake_animals() Keeper.roll_call() Keeper.feed_animals() Keeper.exercise_animals() Keeper.shut_down()
class Zookeeper: zoo_announcers = [] animalsList = [ Cat('Carl'), Cat('Candy'), Dog('Doris'), Dog('Dan'), Elephant('Eric'), Elephant('Earl'), Hippo('Harry'), Hippo('Humphrey'), Lion('Leopold'), Lion('Larry'), Rhino('Rory'), Rhino('Rodger'), Tiger('Terrance'), Tiger('Time'), Wolf('Wallace'), Wolf('Wendy') ] def add_observer(self, zoo_announcer: 'ZooAnnouncer'): self.zoo_announcers.append(zoo_announcer) def notify_observers(self, task: Task): for announcer in self.zoo_announcers: announcer.update(task) def remove_observer(self, zoo_announcer: 'ZooAnnouncer'): self.zoo_announcers.remove(zoo_announcer) def wakeAnimals(self): self.notify_observers(Task.WAKEUP) for animal in self.animalsList: animal.wakeUp() return def feedAnimals(self): self.notify_observers(Task.FEED) for animal in self.animalsList: animal.eat() return def letAnimalsRoam(self): self.notify_observers(Task.LETROAM) for animal in self.animalsList: animal.roam() return def rollCallAnimals(self): self.notify_observers(Task.ROLLCALL) for animal in self.animalsList: animal.makeNoise() return def putAnimalsToBed(self): self.notify_observers(Task.PUTTOBED) for animal in self.animalsList: animal.sleep() return
import Dog mydog = Dog.BenDog("xx", 12, 130) mydog.MyNew() mydog.height = 150 mydog.MyNew()
class Zookeeper: # list of Animals is kept as an attribute of Zookeeper class animalsList = [ Cat('Carl'), Cat('Candy'), Dog('Doris'), Dog('Dan'), Elephant('Eric'), Elephant('Earl'), Hippo('Harry'), Hippo('Humphrey'), Lion('Leopold'), Lion('Larry'), Rhino('Rory'), Rhino('Rodger'), Tiger('Terrance'), Tiger('Time'), Wolf('Wallace'), Wolf('Wendy') ] def main(self): if not os._exists( 'out'): # if out folder doesn't exist, then create one os.mkdir('out') sys.stdout = open(os.path.join('out', 'dayAtTheZoo.out'), 'w') # write all print statements to a file # call wakeAnimals(), rollCallAnimals(), feedAnimals(), letAnimalsRoam(), putAnimalsToBed() in the same order print("The Zookeeper is waking up the animals:\n---") self.wakeAnimals() print("\nThe Zookeeper is doing roll call:\n---") self.rollCallAnimals() print("\nThe Zookeeper is feeding the animals:\n---") self.feedAnimals() print("\nThe Zookeeper is letting the animals roam about:\n---") self.letAnimalsRoam() print("\nThe Zookeeper is putting the animals to bed:\n---") self.putAnimalsToBed() return def wakeAnimals(self): ''' :return: wakeUp() list of Animals one at a time ''' for animal in self.animalsList: animal.wakeUp() return def feedAnimals(self): ''' :return: feedAnimals() list of Animals one at a time ''' for animal in self.animalsList: animal.eat() return def letAnimalsRoam(self): ''' :return: lets list of Animals roam one at a time ''' for animal in self.animalsList: animal.roam() return def rollCallAnimals(self): ''' :return: allows roll call list of Animals one at a time. ''' for animal in self.animalsList: animal.makeNoise() return def putAnimalsToBed(self): ''' :return: allows list of Animals put to bed one at a time. ''' for animal in self.animalsList: animal.sleep() return
from Feline import * from Cat import * from Dog import * from Elephant import * from Hippo import * from Rhino import * from Lion import * from Tiger import * from Wolf import * from ZooKeeperInterface import * if __name__ == "__main__": Cody = Cat("Cody") Code = Cat("Code") Code.setStatus() Donald = Dog("Donald") Dash = Dog("Dash") Dash.setStatus() Eric = Elephant("Eric") Edward = Elephant("Edward") Edward.setStatus() Heman = Hippo("Heman") Heather = Hippo("Heather") Heather.setStatus() Luke = Lion("Luke") Lisa = Lion("Lisa") Lisa.setStatus() Rosy = Rhino("Rosy") Rambo = Rhino("Rambo") Rambo.setStatus() Todd = Tiger("Todd")
from Hippo import * from Lion import * from Rhino import * from Tiger import * if __name__ == "__main__": # The client code. ## setting with stragey pattern WillieWolf = Wolf(FeedWithFear()) WhinnyWolf = Wolf(FeedWithFear()) CarlCat = Cat() CindyCat = Cat() ## setting with stragey pattern DougDog = Dog(FeedWithCare()) DippyDog = Dog(FeedWithCare()) EllyElephant = Elephant() EarlElephant = Elephant() HarryHippo = Hippo() HenryHippo = Hippo() LillyLion = Lion() LarryLion = Lion() RyanRhino = Rhino() RandyRhino = Rhino() TonyTiger = Tiger() TimmyTiger = Tiger() ZaneZooKeeper = ZooKeeper()
zPos = -5.0 # Kameranın Z Konumu yPos = 8.0 # Kameranın Y Konumu zoom = 0.2 # mouse_x = 0 # Mouse Anlık X Konumu mouse_y = 0 # Mouse Anlık Y Konumu mouse_left = 1 # Mouse Tıklandı mı mouseTikX =0 # Mouse Tıklama X Konumu mouseTikY =0 # Mouse Tıklama Y Konumu ''' Oyun ile ilgili temel objelerin oluşturulması ''' game = Game() plusBox = PlusBox() tus = Tus() control = Control() human = Human() dog = Dog() stopTime = 2.0 boxCordinate = [] # Engeller için rastgele koordinatların tutulduğu liste boxList = [] ''' Oyuna yeniden başlama durumunda insan/köpek/kamera konumu gibi değerleri sıfırlayan fonksiyon ''' def restart(): global game,plusBox,tus,control,human,dog,stopTime game.score = 0 plusBox = PlusBox() tus = Tus() control = Control() human = Human() dog = Dog() stopTime = 2.0
import Dog as D import Student as Stu import Restaurant as Res my_dog = D.Dog("二哈", 5) my_dog.sit() my_dog.show() my_dog.roll_over() count = [x for x in range(0, 5)] dogs = [] for v in count: dogs.append(D.Dog("name_" + str(v), v)) a = 0 for d in dogs: print(d.name) a += d.age print(a) print("===============") s = Stu.Student("zzl", '男', 35) s.print_stu_info() s.study('Chinese', 'English', 'French') print("===========") s.study() print("==============") r = Res.Restaurant("福味居", "粤菜") r.open_restaurant() r.describe_restaurant() r.close_restaurant()
import Dog, Cat dog = Dog.Dog() dog.run() cat = Cat.Cat() cat.run() def run_twice(func): func.run() run_twice(dog) run_twice(cat)