Copyright 2024 Andrei-Madalin Coman (comanandreimadalin@gmail.com)
This project is a Java-based framework for simulating and managing banking operations. It supports various commands for account and card management, transactions, and user-related actions. The framework processes JSON input files describing operations and generates JSON output files reflecting the results.
Design Patterns:
SingletonforInputclass.Commandfor all the commands.
-
Commands:
- BaseCommand: Abstract class for all commands.
- Specific Commands: Classes implementing various operations, such as:
AddAccount,AddFunds,SendMoney,DeleteAccount.- Utility commands like
PrintTransactions,PrintUsers, andReport.
-
Exchange:
- Implements currency exchange functionalities (
Exchange).
- Implements currency exchange functionalities (
-
Input:
- Classes for handling input data (
Exchanges,Input,Users).
- Classes for handling input data (
-
Json:
- Custom serializers and deserializers:
- Serializers:
AccountSerializer,CardSerializer, etc. - Deserializers:
InputDeserializer.
- Serializers:
- Custom serializers and deserializers:
-
Transactions:
- BaseTransaction: Abstract class for all transactions.
- Specific Transactions: Classes implementing various transaction types, such as:
CardActionTransaction,PaymentTransaction,TransferTransaction.
-
User:
- User-related entities:
User: Represents a user.Card: Represents a user card.Account: Represents a user account.
- User-related entities:
Main.java:- Main class to run the entire application.
Test.java:- Utility for running single test cases.
- Navigate to
command/specific. - Create a new class that extends
BaseCommand. - Implement the command logic.
- Register the command in the relevant maps in
JsonUtilsandBaseCommandTypeAdapter.
- Navigate to
transactions/specific. - Create a new class that extends
BaseTransaction. - Implement the transaction logic.
- NOTE: You only need to create a new transaction if you want something to be added to the transaction history of that
account, which will be printed only when one of three specific commands is given. If you just want to know that it
executes,
BaseTransactionis good enough.
- Java Development Kit (Minimum JDK 21).
- JSON input files as described below.
- Place input JSON files in the
./inputdirectory. - Run
Main.javato process all input files and generate output. - Use
Test.javato process a single input file and output toout.txt.
ROOT
├── users (Array)
│ ├── User (Object)
│ │ ├── id (String)
│ │ ├── name (String)
│ │ ├── accounts (Array of Objects)
│ │ ├── cards (Array of Objects)
│ └── (Repeat for other users)
├── exchangeRates (Array, Optional)
│ ├── Exchange (Object)
│ │ ├── from (String)
│ │ ├── to (String)
│ │ └── rate (Number)
│ └── (Repeat for other exchangeRates)
└── commands (Array)
├── Command (Object)
│ ├── command (String)
│ ├── timestamp (Number)
│ └── <arguments> (Optional)
└── (Repeat for other commands)
- This framework is designed for processing of predefined actions and is not interactive.