でバンキング アプリケーションを作成しPython
、ここからいくつかのソース コードを読み込んでいます。 Banking Application . クラスは次のbalance
ように定義されています。
class Balance(object):
""" the balance class includes the balance operations """
def __init__(self):
""" instantiate the class """
self.total = 0
def add(self, value):
""" add value to the total
Args:
value (int): numeric value
"""
value = int(value)
self.total += value
def subtract(self, value):
""" subtract value from the total
Args:
value (int): numeric value
"""
value = int(value)
self.total -= value
私の質問
残高の詳細はクラス外でアクセスしてはならないため、属性をかなり変数にする必要があるため、属性self.total
を次のように定義する必要があります。ここで私の考え方は正しいですか?self.__total
private
public