https://github.com/robertpaulp/e-banking-system
OOP course project in Java
https://github.com/robertpaulp/e-banking-system
design-patterns java oop solid-principles
Last synced: 1 day ago
JSON representation
OOP course project in Java
- Host: GitHub
- URL: https://github.com/robertpaulp/e-banking-system
- Owner: robertpaulp
- Created: 2024-10-16T08:51:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-16T08:55:44.000Z (over 1 year ago)
- Last Synced: 2025-02-21T20:18:53.879Z (over 1 year ago)
- Topics: design-patterns, java, oop, solid-principles
- Language: Java
- Homepage:
- Size: 183 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# e-Banking System
## Introduction
This project is a simulation of e-Banking system that allows users to create accounts, add friends, add funds, open accounts in different currencies, exchange currencies, transfer money, buy stocks and recommend stocks based pm Simple Moving Averages (SMA).
The project main focus was to implement **design patterns** and **design principles** in the codebase. Also, the bonus feature of **premium option** required to create a test.
## Features
| Name of the Command | Command | Result | Erros |
|----------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Create an user | CREATE USER `
` | *Won't display anything to the terminal*. | The e-mail address needs to be **unique**. If a user is created with an existing email address, the error will be displayed: `User with already exists`. |
| Add a friend | ADD FRIEND ` ` | *Won't display anything to the terminal*. | If the *user* or the *user to be added* as a friend **does not exist**, the error will be displayed: `User with doesn’t exist`. If the user has **already been added** as a friend, the error will be displayed: `User with is already a friend`. |
| Add an account | ADD ACCOUNT ` ` | *Won't display anything to the terminal*. | If an account with the **same currency already exists**, the error will be displayed: `Account in currency already exists for user`. |
| Add funds | ADD MONEY ` ` | *Won't display anything to the terminal*. | The funds will always be added successfully (the amount is a positive value, the user exists in the system, and the currency type is supported). |
| Exchange currencies | EXCHANGE MONEY ` ` | *Won't display anything to the terminal*. | If there are **not enough funds** in the account with `` to make the exchange, the error will be displayed: `Insufficient amount in account for exchange`. If the amount **transferred exceeds 50%** of the current value of the source account, a **1% fee** will be applied to the transfer (for the source account from which the money is being transferred). |
| Transfer money to a friend | TRANSFER MONEY ` ` | *Won't display anything to the terminal*. | If there are **not enough funds** in the account with `` to make the transfer, the error will be displayed: `Insufficient amount in account for transfer`. If the user with `` is **not friends** with ``, the error will be displayed: `You are not allowed to transfer money to `. |
| Buy stocks | BUY STOCKS ` ` | *Won't display anything to the terminal*. | If there are **not enough funds** in the account with `` to buy the stocks, the error will be displayed: `Insufficient amount in account for buying stocks`. |
| Get recommendation regarding stocks | RECOMMEND STOCKS | {
“stocksToBuy”: [
“AAPL”,
“TSLA”
]
} | The recommendation algorithm will be based on a simplified version of the *Simple Moving Averages (SMAs) Crossover Strategy*.
- Calculate the short-term SMA (last 5 days).
- Calculate the long-term SMA (last 10 days).
- If the short-term average is higher than the long-term average, the stock is added to the recommendation list. To obtain the values, use the file `stocksValues.csv.` |
| List user attributes | LIST USER `` | {
“email”: “john.doe@email.com”,
“firstname”: “John”,
“lastname”: “Doe”,
“address”: “8 Rocky River Road Auburn, NY 13021”,
“friends”: [
“lili@email.com”,
“mike@email.com”
]
} | If the *user* doesn't exist, the error will be displayed: `User with doesn't exist`. |
| List portfolio | LIST PORTFOLIO `` | "stocks":[
{
"stockName":"TSLA",
"amount":20
}
],
"accounts":[
{
"currencyName":"USD",
"amount":"200.10"
}
]
} | If the *user* doesn't exist, the error will be displayed: `User with doesn't exist`. |
| Buy *PREMIUM OPTION*
* A fee of 100 USD will be charged for the premium option as a one-time payment at the time of purchase. | BUY PREMIUM `` | *Won't display anything to the terminal*. | If the *user* doesn't exist, the error will be displayed: `User with doesn’t exist`. If there are **not enough funds in the USD account** to purchase the premium option, the error will be displayed: `Insufficient amount in account for buying premium option`. |
- If a user has purchased the `premium option`, they will have the following advantages:
- There will **no longer be a fee** for currency exchange (a normal account incurs a 1% fee if the exchanged amount exceeds half of the value of the source account).
- Users will benefit from **preferential prices** when buying stocks. Thus, for stocks recommended by the eBanking application, a 5% discount will be applied to the purchase price.
## Design Patterns and Principles
### Design Patterns
- **Decorator Pattern**:
- Used in `Account.java` where `BasicAccount` and its subclasses (`USDAccount`, `EURAccount`, etc.) implement the `Account` interface.
- **Command Pattern**:
- Implemented in `Command.java` with the `Command` interface and its concrete implementations (`UserCommand`, `AccountCommand`, `StockCommand`).
- **Singleton Pattern**:
- Used in `Users.java` to ensure only one instance of the `Users` class exists.
- **Strategy Pattern**:
- Implemented in `Stocks.java` with the `Stocks` interface and its concrete implementations (`BuyStock`, `RecommendStock`).
### SOLID Principles
- **Single Responsibility Principle (SRP)**:
- Each class has a single responsibility, such as `Users` for managing user data, `Portofolio` for managing accounts and stocks, and `ExchangeRates` for handling exchange rates.
- **Open/Closed Principle (OCP)**:
- Classes like `Account` and `Command` are open for extension but closed for modification. New account types or commands can be added without modifying existing code.
- **Interface Segregation Principle (ISP)**:
- The `Account` interface ensures that classes implementing it only need to provide relevant methods.
- **Dependency Inversion Principle (DIP)**:
- High-level modules (`Main.java`) depend on abstractions (`Command`, `Account`) rather than concrete implementations.