在这个锻炼我无法工作,如何进口数据 Person
入 IndividualBankAccount
.
在特定这一行: def __init__(self, sort_code: int, account_number: int, owner: Person):
我不知道什么在这里
super().__init__(sort_code,account_number)
我怎么通过变量的所有者: Person
, 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