V tomto cvičení nemohu přijít na to, jak importovat data z Person
do IndividualBankAccount
.
v konkrétních tento řádek: def __init__(self, sort_code: int, account_number: int, owner: Person):
Nejsem si jistý, co se děje tady
super().__init__(sort_code,account_number)
Jak mohu předat proměnné majitel: Person
k super()
?
class Person:
_first_name : str
_second_name : str
_address : str
def __init__(self, fn: str, ln: str):
"creates a new person with first name fn last name ln and empty address"
self._first_name=fn
self.second_name=ln
class BankAccount:
_sort: int
_account_num: int
def __init__(self, sort_code: int, account_number: int)-> None:
'''creates a bank account with given sort code and account number'''
self._sort=sort_code
self._account_num=account_number
class IndividualBankAccount(BankAccount):
_owner: Person
def __init__(self, sort_code: int, account_number: int, owner: Person):
'''creates a new bank account with given sort code, account number, and owner'''
super().__init__(sort_code,account_number)
self._owner = owner
def get_account_data(self)-> str:
'''returns string "FN LN SC AN" where FN and LN are owner's first and last names,
SC is sort code, AN is account number'''
my_string =f"{XXXXwhat goes here???XXXX}"
return my_string