Created
November 25, 2022 12:08
-
-
Save Mishco/d9946c1677f18207d1d7a1fccee513f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class Account { | |
| protected abstract void deposit(BigDecimal amount); | |
| protected abstract void withdraw(BigDecimal amount); | |
| } | |
| /** | |
| * Empty method | |
| */ | |
| public class FixedTermDepositAccount extends Account { | |
| protected void deposit(BigDecimal amount) { | |
| // Deposit into this account | |
| } | |
| protected void withdraw(BigDecimal amount) { | |
| // Empty method | |
| } | |
| } | |
| /** | |
| * Or throw exception | |
| */ | |
| public class FixedTermDepositAccount extends Account { | |
| @Override | |
| protected void deposit(BigDecimal amount) { | |
| // Deposit into this account | |
| } | |
| @Override | |
| protected void withdraw(BigDecimal amount) { | |
| throw new UnsupportedOperationException("Withdrawals are not supported by FixedTermDepositAccount!!"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment