instance variables
= data member
method
= member function
좋은 코드의 조건
만약 어떤 새가 오리처럼 걷고, 헤엄치고, 꽥꽥거리는 소리를 낸다면 나는 그 새를 오리라고 부를 것이다.
class CreditCard:
def __init__(self, customer, bank, acnt, linit):
self._customer = customer
selr._bank = bank
self._account = acnt
self._limit = limit
self._balance = 0
def get_customer(self):
return self._customer
def get_bank(self):
return self._bank
def get_account(self):
return self._account
def get_limit(self):
return self._limit
def get_balance(self):
return self._balance
def charge(self, price):
if price + self._balance > self._limit:
return False
else:
self._balance += price
return True
def make_payment(self, amount):
self._balance -= amount
cc = CreditCard('John Doe`, `1st Bank', '5391 0375 9387 5309', 1000)
class FibonacciProgression(Progression):
def __init__(self, first = 0, second = 1):
super().__init__(first)
self._prev = seconde - first
def _advance(self):
self._prev, self._current = self._current, self._prev + self._current