How joeandreroja/roja_decoratorpattern works
This is a small Java example of CIMB savings accounts implemented with the Decorator pattern. The Cimb entry point creates a standard account, populates its details, and prints its information and interest calculation; it then wraps that account as GSave and UpSave to display their rates and additional benefits. The excerpts show each decorator delegating account details and benefits to its wrapped BankAccount. No persistence or external services are shown.
Main entry points: Cimb.java Cimb entry point · BankAccount.java Account contract · GSave.java GSave decorator · UpSave.java UpSave decorator
Components 7
Other components
- Example runner
- Cimb entry point
decoratorPattern/Cimb.java - Savings account
decoratorPattern/SavingsAccount.java - GSave decorator
decoratorPattern/GSave.java - UpSave decorator
decoratorPattern/UpSave.java - Account contract
decoratorPattern/BankAccount.java - Decorator contract
decoratorPattern/BankAccountDecorator.java
Connections 10
- Example runner → Cimb entry point: runs
- Cimb entry point → Savings account: creates
decoratorPattern/Cimb.java - Cimb entry point → GSave decorator: wraps account
decoratorPattern/Cimb.java - Cimb entry point → UpSave decorator: wraps account
decoratorPattern/Cimb.java - Savings account → Account contract: implements
decoratorPattern/SavingsAccount.java - Decorator contract → Account contract: extends
decoratorPattern/BankAccountDecorator.java - GSave decorator → Decorator contract: implements
decoratorPattern/GSave.java - UpSave decorator → Decorator contract: implements
decoratorPattern/UpSave.java - GSave decorator → Account contract: delegates to
decoratorPattern/GSave.java - UpSave decorator → Account contract: delegates to
decoratorPattern/UpSave.java