Advertisement
fkudinov

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

Dec 7th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 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.  
  11.     assert fight(chuck, bruce) == True
  12.     assert fight(dave, carl) == False
  13.     assert chuck.is_alive == True
  14.     assert bruce.is_alive == False
  15.     assert carl.is_alive == True
  16.     assert dave.is_alive == False
  17.     assert fight(carl, mark) == False
  18.     assert carl.is_alive == False
  19.  
  20.     #battle tests
  21.     my_army = Army()
  22.     my_army.add_units(Knight, 3)
  23.    
  24.     enemy_army = Army()
  25.     enemy_army.add_units(Warrior, 3)
  26.  
  27.     army_3 = Army()
  28.     army_3.add_units(Warrior, 20)
  29.     army_3.add_units(Knight, 5)
  30.    
  31.     army_4 = Army()
  32.     army_4.add_units(Warrior, 30)
  33.  
  34.     battle = Battle()
  35.  
  36.     assert battle.fight(my_army, enemy_army) == True
  37.     assert battle.fight(army_3, army_4) == False
  38.     print("Coding complete? Let's try tests!")
Tags: checkio
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement