Домашни > Хелоуин в Припят > Решения > Решението на Атанас Христов

Резултати
8 точки от тестове
0 точки от учител

8 точки общо

10 успешни теста
2 неуспешни теста
Код
Скрий всички коментари

 1class Candy:
 2    def __init__(self, mass, uranium):
 3        self.mass = mass
 4        self.uranium = uranium
 5        
 6    def get_uranium_quantity(self):
 7        return self.mass * self.uranium
 8    
 9    def get_mass(self):
10        return self.mass
11    
12class Person:
13    def __init__(self, position):
14        self.position = position
15        
16    def get_position(self):
17        return self.position
18    
19    def set_position(self, new_position):
20        self.position = new_position
21        
22class Kid(Person):
23    def __init__(self, position, initiative):
24        super().__init__(position)
25        self.initiative = initiative
26        self.bucket = list()
27        self.uranium_in_bucket = 0
28        
29    def get_initiative(self):
30        return self.initiative
31    
32    def add_candy(self, candy):
33        self.bucket.append(candy)
34        self.uranium_in_bucket += candy.get_uranium_quantity()
35        
36    def is_critical(self):
37        return self.uranium_in_bucket > 20 # Make constant
38    
39class Host(Person):
40    def __init__(self, position, candies):
41        super().__init__(position)
42        self.bucket = list(Candy(x, y) for x,y in candies)
43    
44    def remove_candy(self, func):
45        if self.bucket:
46            return func(self.bucket)
47        
48class FluxCapacitor:
49    def __init__(self, participants):
50        self.participants = participants
51        
52    def get_victim(self):
53        pass

.....FF.....
======================================================================
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 0x7ff39374f1c0>,[36 chars]bd0>}

======================================================================
FAIL: test_basic_usage (test.HostTest)
Test basic usage of Host class.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 68, in test_basic_usage
self.assertEqual(candy.get_mass(), 785)
AssertionError: 456 != 785

----------------------------------------------------------------------
Ran 12 tests in 0.001s

FAILED (failures=2)

Дискусия
Виктор Бечев
08.11.2023 12:38

Бих казал изчистено решение, ама реално е без най-тегавата част.
История
Това решение има само една версия.