02. class 예제
하나의 은행 계좌를 관리하는 클래스를 구현하세요
- class 명 : Account
- 입금, 출금, 잔액확인이 가능합니다.
class Account:
def __init__(self, number, balance=0):
self.__number = number
self.__balance = balance
def getBalance(self):
return self.__balance
def deposit(self, money):
self.__balance += money
def withdraw(self, money):
self.__balance -= money
def showBalance(self):
print(f"잔 액 : {self.__balance}")
def info(self):
print("--- 계 좌 정 보 ---")
print(f"계좌번호 : {self.__number}")
print(f"잔 액 : {self.__balance}")
memberA = Account("000123-10-123")
memberA.info()
print()
print("- 입 금 -")
memberA.deposit(20000)
memberA.showBalance()
print()
print("- 출 금 -")
memberA.withdraw(7000)
memberA.showBalance()
print()
memberA.info()
