class CatTest(unittest.TestCase): def setUp(self): self.cat = Cat('Aggressive', 'Ginger', 'Mufasa', True, 'Tabby', 5) def test_attack(self): self.assertEqual(self.cat.attack(), 'HISS') self.cat.sleepy = True self.assertEqual(self.cat.attack(), 'HISS') self.cat.behaviour = 'Not Aggressive' self.assertEqual(self.cat.attack(), '*snore*') def test_chase(self): self.assertEqual(self.cat.chase('mouse'), 'Come here Jerry') self.assertEqual(self.cat.chase('rabbit'), 'Not interested') def test_play(self): self.assertEqual(self.cat.play('box'), 'If I fits....') self.assertEqual(self.cat.play('new toy'), "Erm no. Where's the box?") def test_eat(self): self.assertEqual(self.cat.eat('tuna'), 'Really? Im trying to sleep here') self.cat.sleepy = False self.assertEqual(self.cat.eat('tuna'), f'OOOH, Tuna')
from cat_class import Cat cat = Cat('Кошка', 12, 'Синий') print(cat.name) cat.mew() print(cat.get_age()) cat.set_age(13) print(cat.get_age()) cat.set_age(50) print(cat.get_age()) print(cat.get_color())
from dog_class import Dog from cat_class import Cat # Initialise dog object (name, age, coat, colour, tail) clifford_dog = Dog(age=4) print(clifford_dog.age) print(clifford_dog.tail) # call method .bark() print(clifford_dog.bark()) # calling multiple arg function .eat() print(clifford_dog.eat("toxic waste")) # Initialise cat object (name, age, fur, colour, tail, claws) sylvester_cat = Cat(age=10) # call method .purr() print(sylvester_cat.purr()) # .eat() print(sylvester_cat.eat("fish"))
def setUp(self): self.cat = Cat('Aggressive', 'Ginger', 'Mufasa', True, 'Tabby', 5)
from cat_class import Cat c1 = Cat("Барон", "male", 2) c2 = Cat("Сэм", "male", 2) print(c1.info()) print(c2.info())
# import classes here and intialize objs and run methods # this speration will maintain you code more organized following speration of concerns from dog_class import Dog from cat_class import Cat # Initialize a Dog object - max_dog_instance = Dog(name='Max') ringo_dog_instance = Dog(age=10, name='Ringo') # initialize a Cat object - garfield = Cat(name='Garfield the Lasanha Monster') print(max_dog_instance) print(garfield) print(max_dog_instance.name) print(ringo_dog_instance.name) # # Call the method .bark() on object # print(max_dog_instance.eat('BONE')) print(max_dog_instance.bark()) print(max_dog_instance.fetch()) print(max_dog_instance.potty()) print(max_dog_instance.bark()) print(max_dog_instance.sleep()) print(max_dog_instance.reproduce()) # print('walk the dog home') # # print(max_dog_instance.sleep())
wall3.rect.x = SCREENWIDTH / 3 wall3.rect.y = 600 wall4 = wall(WALLCOLOUR, 100, 250) wall4.rect.x = SCREENWIDTH / 3 * 2 wall4.rect.y = 550 wall5 = wall(WALLCOLOUR, 100, 400) wall5.rect.x = 0 wall5.rect.y = SCREENHEIGHT / 2 wall6 = wall(WALLCOLOUR, 100, 250) wall6.rect.x = 900 wall6.rect.y = SCREENHEIGHT / 2 cat1 = Cat(100, 80) cat1.rect.x = 100 cat1.rect.y = 625 cat2 = Cat(100, 80) cat2.rect.x = 500 cat2.rect.y = 500 cat3 = Cat(100, 80) cat3.rect.x = 700 cat3.rect.y = 50 #all_player_list = pygame.sprite.Group() all_enemy_sprites = pygame.sprite.Group() all_treasure_list = pygame.sprite.Group() all_exitDoor_list = pygame.sprite.Group()