Skip to content

A Java program for EBU6304 (2022/23), which implements a basic bank account management system, allowing users to create accounts, deposit and withdraw money, and manage their accounts.

Notifications You must be signed in to change notification settings

Wiederholung/Simple-Banking-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Banking System

Personal Project of EBU6304 Software Engineering (2022/23)

This is a Java project that implements a basic bank account management system, allowing users to create accounts, deposit and withdraw money, and manage their accounts.

Features

  • Multiple account types, including savings, CurrentAccount, and JuniorAccount
  • Withdraw policy for CurrentAccount and JuniorAccount
  • Ability to suspend and close accounts
  • Java unit tests for each account type and the Bank class
  • Data persistence using JSON (v1)
  • Ability to change the type of account (v2)
  • Fast lookup enabled by HashMap (v3)

Getting Started

Prerequisites

  • IntelliJ IDEA (recommended)
  • Java Development Kit (JDK) 8 or later
  • Maven 3.2 or later

Installation

  1. Clone the repository:

    git clone https://github.com/Wiederholung/Simple-Banking-System.git
  2. Navigate to the directory where you downloaded the repository:

    cd Simple-Banking-System

    Optional: open the project in IDEA

  3. Compile: mvn compile

  4. Run unit tests: mvn test

Usage

You can create different types of accounts with varying properties and features. A sample code shows how to create an account and perform some actions on it:

package com.metattri.se;

import java.io.IOException;

public class Sample {
    public static void main(String[] args) {
        Bank bank;
        try {
            bank = new Bank();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        System.out.println("new account number: " + bank.openAccount(new CurrentAccount("your name")));

        bank.deposit("test", 500.0);
        bank.withdraw("test", 1000.0);
        System.out.println(bank.checkBalance("test"));

        bank.suspendAccount("test", true);
        assert !bank.deposit("test", 1000.0);
        bank.suspendAccount("test", false);

        String newAccNo = null;
        try {
            newAccNo = bank.changeAccountType("test", "CurrentAccount");
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }
        System.out.println("new account number: " + newAccNo);

        bank.closeAccount(newAccNo);

        bank.printAccounts();
    }
}

Note

  1. See more usage in the JUnit tests and design details in the UML diagram.

  2. The account number is a UUID, which is a random string. You can look up the account number via:

    • bank.printAccounts();
    • String accNo = bank.openAccount(new BankAccount("your name"));
    • accounts.json
  3. The database file accounts.json is stored in the directory src/main/resources, which is the default directory for resources in Maven. You can change the directory in the Bank.java file.

  4. After running the JUnit tests or Sample.java, you can check the database file to see the changes.

  5. Remember to rollback the changes in the accounts.json if you want to run the tests again.

Contributor

About

A Java program for EBU6304 (2022/23), which implements a basic bank account management system, allowing users to create accounts, deposit and withdraw money, and manage their accounts.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages