1class Candy:
2
3 def __init__(self, mass, uranium):
4 self.mass = mass
5 self.uranium = uranium
6
7 def get_uranium_quantity(self):
8 return self.mass*self.uranium
9
10 def get_mass(self):
11 return self.mass
12
13
14class Person:
15
16 def __init__(self, position):
17 self.position = position
18
19 def get_position(self):
20 return self.position
21
22 def set_position(self, new_position):
23 self.new_position = new_position
24
25
26class Kid:
27
28 def __init__(self, position, initiative):
29 self.position = position
30 self.initiative = initiative
31 self.basket = []
32
33 def get_initiative(self):
34 return self.initiative
35
36 def add_candy(self, candy):
37 self.basket.append(candy)
38
39 def is_critical(self):
40 total_mass = sum(candy.get_uranium_quantity() for candy in self.basket)
41 return total_mass > 20
42
43
44class Host(Person):
45
46 def __init__(self, position, candies):
47 super().__init__(position)
48 self.basket = [Candy(mass, uranium) for mass, uranium in candies]
49
50 def remove_candy(self, selector):
51 if not self.basket:
52 return None
53 selected_candy = selector(self.basket)
54 self.basket.remove(selected_candy)
55 return selected_candy
56
57
58class FluxCapacitor:
59
60 def __init__(self, participants):
61 self.participants = participants
62
63 def get_victim(self):
64 kids_positions = {}
.....F..E.FF
======================================================================
ERROR: test_basic_usage (test.KidTest)
Test basic usage of Kid class.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 39, in test_basic_usage
self.assertEqual(kid.get_position(), (0, 0))
AttributeError: 'Kid' object has no attribute 'get_position'
======================================================================
FAIL: test_real_case (test.FluxCapacitorTest)
Test with real case.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/timeout_decorator/timeout_decorator.py", line 82, in new_function
return function(*args, **kwargs)
File "/tmp/test.py", line 115, in test_real_case
self.assertEqual(FluxCapacitor({kid1, kid2, host1, host2}).get_victim(), {kid1, kid2})
AssertionError: None != {<solution.Kid object at 0x7f88c518f1c0>,[36 chars]bd0>}
======================================================================
FAIL: test_inheritance (test.KidTest)
Ensure Kid inherits from Person.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 34, in test_inheritance
self.assertTrue(issubclass(Kid, Person))
AssertionError: False is not true
======================================================================
FAIL: test_basic_usage (test.PersonTest)
Test basic usage of Person class.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 26, in test_basic_usage
self.assertEqual(person.get_position(), (2, 2))
AssertionError: Tuples differ: (0, 0) != (2, 2)
First differing element 0:
0
2
- (0, 0)
+ (2, 2)
----------------------------------------------------------------------
Ran 12 tests in 0.001s
FAILED (failures=3, errors=1)
08.11.2023 13:13