Advertisement
fkudinov

15.3 Епічна Битва між 2 Арміями / Вирішуємо задачі на Python CheckIO Українською

Dec 7th, 2023
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | Source Code | 0 0
  1. if __name__ == '__main__':
  2.     #These "asserts" using only for self-checking and not necessary for auto-testing
  3.    
  4.     #fight tests
  5.     chuck = Warrior()
  6.     bruce = Warrior()
  7.     carl = Knight()
  8.     dave = Warrior()
  9.     mark = Warrior()
  10.     bob = Defender()
  11.     mike = Knight()
  12.     rog = Warrior()
  13.     lancelot = Defender()
  14.  
  15.     assert fight(chuck, bruce) == True
  16.     assert fight(dave, carl) == False
  17.     assert chuck.is_alive == True
  18.     assert bruce.is_alive == False
  19.     assert carl.is_alive == True
  20.     assert dave.is_alive == False
  21.     assert fight(carl, mark) == False
  22.     assert carl.is_alive == False
  23.     assert fight(bob, mike) == False
  24.     assert fight(lancelot, rog) == True
  25.  
  26.     #battle tests
  27.     my_army = Army()
  28.     my_army.add_units(Defender, 1)
  29.    
  30.     enemy_army = Army()
  31.     enemy_army.add_units(Warrior, 2)
  32.  
  33.     army_3 = Army()
  34.     army_3.add_units(Warrior, 1)
  35.     army_3.add_units(Defender, 1)
  36.  
  37.     army_4 = Army()
  38.     army_4.add_units(Warrior, 2)
  39.  
  40.     battle = Battle()
  41.  
  42.     assert battle.fight(my_army, enemy_army) == False
  43.     assert battle.fight(army_3, army_4) == True
  44.     print("Coding complete? Let's try tests!")
Tags: checkio
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement