Self Check

     

    고객계좌 클래스와 은행 클래스를 정의해 금융 거래 프로그램을 작성하려고 합니다. 다음은 각 클래스가 가져야 하는 조건과 완성된 클래스의 일부입니다. 내용을 보고 다음 물음에 답하세요.

    |조건|

    • 고객계좌 클래스(Customer_account)는 고객이름과 잔고를 속성으로 가지며, 메서드는 없습니다.

    • 은행 클래스(Bank)는 3개의 메서드가 있습니다. 계좌에 입금하는 deposit(), 계좌에서 출금하는 withdrawal(), 한 계좌에서 다른 계좌로 이체하는 send_money()입니다.

    • 은행 클래스의 각 메서드는 고객계좌 객체와 거래금액을 인자로 전달받아 고객계좌 객체의 거래금액만큼 잔고를 수정합니다.

    # 계좌 클래스
    class Customer_account:
        def __init__(self, name, bal):
            self.name = name
            self.balance = bal # 통장 잔고
            print(self.name, '고객님! 계좌를 개설했습니다. 잔고는', self.balance, '원')
    
    # 은행 클래스
    class Bank:
        # 입금 거래, customer에 customer_account 객체 전달
        def deposit(self, customer, amount):
            (가)
            print(customer.name, '고객님', amount, '원 입금')
            print('입금 후 잔고는', customer.balance, '원')
    
        # 출금 거래, customer에 customer_account 객체 전달
        def withdrawal(self, customer, amount):
            (나)
            print(customer.name, '고객님', amount, '원 출금')
            print('출금 후 잔고는', customer.balance, '원')
    
        # 계좌이체 거래, sender와 reciever에 customer_account 객체 전달
        def send_money(self, sender, reciever, amount):
            (다)
            print(sender.name, '고객님이', reciever.name, '고객님께', amount, '원 송금')
            print('이체 후 잔고는', sender.name, sender.balance, reciever.name, reciever.balance)
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.