Skip to content

Instantly share code, notes, and snippets.

@Mishco
Created November 25, 2022 12:08
Show Gist options
  • Select an option

  • Save Mishco/d9946c1677f18207d1d7a1fccee513f4 to your computer and use it in GitHub Desktop.

Select an option

Save Mishco/d9946c1677f18207d1d7a1fccee513f4 to your computer and use it in GitHub Desktop.
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