Simple bank account application

Includes the usage of the singleton pattern and state design pattern. Has an implemented graphical user interface.

  • Java
  • JavaFX
  • Application of design patterns

Design process

The use case diagram demonstrates the interaction between the manager and a customer to the bank system. The Manager actor is able to login, logout, add a customer, and delete a customer. If the Manager is to add and delete a customer or logout, they must login. Additionally, to add a customer they must make a deposit. The Customer actor is able to login, logout, make a deposit, make a withdrawal, get their balance, and make an online purchase. If the Customer wishes to make a deposit, withdrawal, view their balance, or logout, they must login.

The class diagram describes the banking system. The banking system has a manager and either zero or more customers. A customer has an account that can be of three levels: silver, gold, and platinum. Hence, there is a Manager, Customer, Account, LevelSilver, LevelGold, and LevelPlatinum class. The Manager class follows a singleton pattern as there can only be one manager instance. It has a private constructor and a public static method. When a manager adds a new customer using the addCustomer method, two other methods from the Customer class are class. So, the Manager class depends on the Customer class. The Customer class contains an instance variable account and the method setLevel which uses a type Account, so there is an aggregation relationship between the two classes. The methods deposit, withdraw, and onlinePurchase use methods from the Account class so there is a dependency relationship. Within the Customer class, there is an Overview clause, abstraction function, rep invariant, and necessary clauses for each method. The abstract function is implemented in the toString method and rep invariant is implemented in the repOK method. The classes Account, LevelSilver, LevelGold, and LevelPlatinum form the State design pattern. The Account class is an abstract class which the concrete state classes LevelSilver, LevelGold, and LevelPlatinum inherit from. The concrete state classes override the method changeLevel which is responsible for changing the state(level) of the account within the Customer class. They override the method onlinePurchase which has different functions based on the current state of the customer's account.