Reuse with Components

You work for a small Canadian credit union. You have developed a JavaBean component called
BankAccountBean that provides basic deposit and withdraw functions, and notifies listeners
when large transactions are made and when an account’s balance goes below a threshold.
Review the BankAccount* and Account* code, and run the test code to see the current
behavior.
Part A: Connecting Components
You want to add transaction recording functionality for bank accounts. A transaction is any
operation that changes an account’s balance. Rather than implement this from scratch, you
purchase a TimestampedEventRecorder component from Beans-R-Us, Inc1
. Now you need to
connect this component to your bank account component.
Review the TimestampedEvent* code, and run the test code to see the current behaviour.

  1. JavaBeans are typically connected via events (i.e., by following the Observer design pattern).
    Because the TimestampedEventRecorder component is purchased, you won’t make any
    changes to that code. Instead, update your BankAccountBean so that it generates
    TimestampedEvents. You will use this to record transactions: each TimestampedEvent will have
    a description of the transaction it represents (you decide the format and details of the
    description).
  2. Update the bank account test routine so that it registers a TimestampedEventRecorder to 3
    BankAccountBeans as a listener for TimestampedEvents, executes a number of transactions for
    each of the bank accounts, then outputs the record of TimestampedEvents that were captured.
    Part B: Composing Components
    The credit union is planning to provide online banking services. Desired features include:
  • Depositing into an account.
  • Withdrawing from an account.
  • Getting an account’s balance.
  • Transferring funds from one account into another account.
  • Reviewing the past N transactions for a given account (just output these to the console).
    1 An external JavaBean would typically be provided in a .jar file. In this assignment the codebase is provided as a
    set of .java files instead, to allow you to review the code, and to simplify compilation.
    CSCI 3132: Object-Oriented and Generic Programming Winter 2022
    You plan on sourcing a component that will help with user authentication, but for now you
    want to focus on the feature set listed here.
  1. Use the Façade design pattern to create an OnlineBanking class. This class provides access to
    the feature set by implementing methods that feed forward to the corresponding methods in
    BankAccountBean and TimestampedEventRecorder. All methods will take one or more account
    IDs in its parameter list. Your OnlineBanking class should maintain a Map that connects these
    IDs to the associated BankAccountBean objects (in future, you plan to replace this with a
    database lookup). Do not make any changes to the existing bank account and timestamped
    event code when creating this OnlineBanking class.
  2. Create an online banking test class. This class should create 3 accounts, associate a
    timestamped event recorder with the accounts, and add the accounts to an OnlineBanking
    object. Write test code that demonstrates each of the required features.
    Bonus (optional): add an OnlineBanking feature that retrieves all anomalous events associated
    with an account. To accomplish this:
  • add a method to OnlineBanking that takes an account ID and outputs any associated
    anomalous events to the console