from bankaccount import BankAccount


class SavingsAccount(BankAccount):
    def __init__(self, number, balance=0, interest_rate=0.05):
        if interest_rate < 0:
            raise ValueError("Interest rate cannot be negative.")
        super().__init__(number, balance)
        self.interest_rate = interest_rate

    def get_interests(self):
        return self.balance * self.interest_rate

    def capitalize(self):
        self.balance += self.get_interests()


if __name__ == "__main__":
    savings_account = SavingsAccount("1234-SAVE-0001", 5000, 0.08)
    print(savings_account)  # 1
    print('Next interests: ' + str(savings_account.get_interests()))  # 2

    for i in range(3):
        print('Capitalizing...')  # 3, 5, 7
        savings_account.capitalize()
        print(savings_account)  # 4, 6, 8

    print('Next interests: ' + str(savings_account.get_interests()))  # 9

    account = BankAccount("1234-1111-0001", 30000)
    # account.capitalize()  # niedostępne dla BankAccount!
    print(account) # 10
