Решение на Родословно дърво от Даная Георгиева

Обратно към всички решения

Към профила на Даная Георгиева

Резултати

  • 0 точки от тестове
  • 0 бонус точки
  • 0 точки общо
  • 0 успешни тест(а)
  • 11 неуспешни тест(а)

Код

class Person:
first_name = ""
last_name = ""
birth_year = ""
gender = ""
mother = ""
father = ""
children = []
def name (self):
return "{} {}". format(self.first_name, self.last_name)
def b_year (self):
return "{}". format(self.birth_year)
def gender(self):
return "{}". format (self.gender)
def setmother(self, mother):
if self.birth_year - mother.birth_year >= 18:
self.mother = mother
return self.mother
return None
def setfather(self, father):
if self.birth_year - father.birth_year >= 18:
self.father = father
return self.father
return None
def get_children(self, gender = ['M', 'F']):
children = []
for child in self.children:
if child.gender in gender:
children.append(child)
return children
def getbrothers(self):
brothers = []
if self.mother != "":
for child in self.mother.get_children(['M']):
if child is not self:
brothers.append(child)
if self.father != "":
for child in self.father.get_children(['M']):
if child is not self and child not in brothers:
brothers.append(child)
return brothers;
def getsisters(self):
sisters = []
if self.mother != "":
for child in self.mother.get_children(['F']):
if child is not self:
sisters.append(child)
if self.father != "":
for child in self.father.get_children(['F']):
if child is not self and child not in sisters:
sisters.append(child)
return sisters;
#konstruktor
def __init__(self, first_name, last_name, birth_year, gender):
self.first_name = first_name
self.last_name = last_name
self.birth_year = birth_year
self.gender = gender

Лог от изпълнението

EEEEEEEEEEE
======================================================================
ERROR: test_attributes (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_children (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_father_has_daughter (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_father_has_son (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_has_brother (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_has_no_brother (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_has_no_sister (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_has_sister (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_indirect_successor (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_mother_has_daughter (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

======================================================================
ERROR: test_mother_has_son (test.PersonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130408-29081-gn03mb/test.py", line 7, in setUp
    self.adam = solution.Person(name='Adam', gender='M', birth_year=0)
TypeError: __init__() got an unexpected keyword argument 'name'

----------------------------------------------------------------------
Ran 11 tests in 0.003s

FAILED (errors=11)

История (1 версия и 0 коментара)

Даная обнови решението на 01.04.2013 14:48 (преди около 11 години)

+class Person:
+ first_name = ""
+ last_name = ""
+ birth_year = ""
+ gender = ""
+ mother = ""
+ father = ""
+ children = []
+
+ def name (self):
+ return "{} {}". format(self.first_name, self.last_name)
+ def b_year (self):
+ return "{}". format(self.birth_year)
+ def gender(self):
+ return "{}". format (self.gender)
+ def setmother(self, mother):
+ if self.birth_year - mother.birth_year >= 18:
+ self.mother = mother
+ return self.mother
+ return None
+ def setfather(self, father):
+ if self.birth_year - father.birth_year >= 18:
+ self.father = father
+ return self.father
+ return None
+ def get_children(self, gender = ['M', 'F']):
+ children = []
+ for child in self.children:
+ if child.gender in gender:
+ children.append(child)
+ return children
+ def getbrothers(self):
+ brothers = []
+ if self.mother != "":
+ for child in self.mother.get_children(['M']):
+ if child is not self:
+ brothers.append(child)
+ if self.father != "":
+ for child in self.father.get_children(['M']):
+ if child is not self and child not in brothers:
+ brothers.append(child)
+ return brothers;
+ def getsisters(self):
+ sisters = []
+ if self.mother != "":
+ for child in self.mother.get_children(['F']):
+ if child is not self:
+ sisters.append(child)
+ if self.father != "":
+ for child in self.father.get_children(['F']):
+ if child is not self and child not in sisters:
+ sisters.append(child)
+ return sisters;
+
+#konstruktor
+ def __init__(self, first_name, last_name, birth_year, gender):
+ self.first_name = first_name
+ self.last_name = last_name
+ self.birth_year = birth_year
+ self.gender = gender