【发布时间】:2022-01-09 06:56:34
【问题描述】:
我很难弄清楚如何从 vscode 更新方法的选定引用。右键单击方法名称不会提供选择和更新引用的选项。 Python 和 vscode 的新手,并试图找出它周围的细微差别。请有人帮我解决这个问题!
这是课程 - 我有一个课程Player_Account
class Player_Account:
def __init__(self,owner,balance):
self.owner = owner
self.balance = balance
def deposit(self,balance):
self.balance += balance
return "Amount added to players pot !"
def withdraw(self,amount): # I need to update this method name to withdraw_amount
if self.balance<amount:
return "Funds Unavailable"
else:
self.balance -= amount
return "Money added to hand !"
def __str__(self):
return f"Account owner : {self.owner} has outstanding balance of {self.balance}"
另一个班级Player
class Player:
def __init__(self,name):
self.name=name
self.hand = []
self.player_account:Player_Account = Player_Account(name,0)
def initial_money(self,amount):
self.player_account.balance = amount
def player_won_the_hand(self,amount):
self.player_account.deposit(amount)
return True
def player_betting_amount_for_the_round(self,amount):
value = self.player_account.withdraw(amount) # I need this reference to be automatically updated as well
if value == 'Funds Unavailable':
return False
else:
return True
【问题讨论】:
-
return value != 'Funds Unavailable'