Question: Problem Description In this assignment you will implement a Distributed Banking System that consists of a server and some simulated Automated Teller Machine (ATM) clients.

Problem Description

In this assignment you will implement a Distributed Banking System that consists of a server and some simulated Automated Teller Machine (ATM) clients. The server manages all users account information. A customer can invoke the following operations at an ATM client.

  1. void deposit(int accnum, Money amt): this operation increases the balance of user account accnum by amt, and returns nothing
  2. withdraw(int accnum, Money amt): this operation decreases the balance of user account accnum by amt, and returns nothing
  3. Money getBalance(int accnum): this operation returns the balance of user account accnum
  4. Statement getStatement(int accnum, Date from, Date to): this operation returns an account statement object encapsulating transactions over a time period

System Requirements

You are required to write this client-server (banking system) application which communicates via Java RMI. Specifically, your program should consist of two parts: one for the client and another for the server. The client (as the ATM) will initiate an operation by calling a remote method on the bank server to execute a specified procedure (e.g. deposit) with parameters. Please use the Joda-Money library class Money as the type for the Money parameter used in the various operations. See https://www.joda.org/joda-money/ for details. You may have to download the attached Joda-Money library (JAR File) and include this in your CLASSPATH or IDE Project Libraries to use this class.

You can use the following interface and class definitions as a starting point for your project. However, you are free to develop your own interface and class definitions so long as the basic requirements are still met e.g. you might want to add more exception handling to the remote methods or add some additional features as you see fit.

Remote Interface

public interface BankInterface extends Remote {

// The login method returns a token that is valid for some time period that must be passed to the other methods as a session identifier

public long login(String username, String password) throws RemoteException, InvalidLogin;

public void deposit(int accountnum, Money amount, long sessionID) throws RemoteExcept, InvalidSession;

public void withdraw(int accountnum, Money amount, long sessionID) throws RemoteException, InvalidSession;

public Money getBalance(int accountnum, long sessionID) throws RemoteException, InvalidSession;

public Statement getStatement(Date from, Date to, long sessionID) throws RemoteException, InvalidSession;

}

Statement Interface

public interface Statement extends Serializable {

public int getAccountnum(); // returns account number associated with this statement

public Date getStartDate(); // returns start Date of Statement

public Date getEndDate(); // returns end Date of Statement

public String getAccoutName(); // returns name of account holder

public List getTransactions(); // return list of transactions included in this statement

}

Transaction class

public class Transaction extends Serializable {

// Needs some accessor methods to return information about the transaction

public Money getAmount();

public Date getDate();

public String description;

}

Server Definition

public class Bank implements BankInterface {

private List accounts; // users accounts

public Bank() throws RemoteException {

} public void deposit(int account, Money amount) throws RemoteException, InvalidSession {

// implementation code

}

public void withdraw(int account, Money amount) throws RemoteException, InvalidSession {

// implementation code

}

public Money getBalance(int account) throws RemoteException, InvalidSession {

// implementation code

}

public Statement getStatement(Date from, Date to) throws RemoteException, InvalidSession {

// implementation code

}

public static void main(String args[]) throws Exception {

// initialise Bank server - see sample code in the notes and online RMI tutorials for details

}

}

The Bank server should be initialised with a number of test accounts that have various balances that can then be accessed by the ATM clients.

You will need to define suitable classes for Account and Transaction and also provide a class that implements the Statement interface.

Client side - ATM Class

public class ATM {

public static void main (String args[]) throws Exception {

// get users input, and perform the operations

}

}

The command line parameters of the ATM client application will include:

  • operation: one of "login", "deposit", "withdraw", and "balance"
  • account: the user account
  • username: only for "login" operation
  • password: only for "login" operation
  • amount: only for deposit and withdraw operations

The ATM client application can be run at the command line using the parameters shown and, to save time, a full GUI based client application is not required. The first operation that is called is login and if this succeeds a session ID is returned which is then valid for some predefined time period. This session ID then acts as an authentication token that must be passed for each of the other remote methods. Running the application on a windows PC will then look something like this:

C:\>rmiregistry

Then, start the server in a different command line window

C:\>java Bank

Finally, test the ATM client application in another command line window

C:\>java ATM login user1 secret

Successful login for user1 : session ID 39948872203 is valid for 5 minutes

C:\>java ATM 39948872203 balance 12345678

The current balance of account 12345678 is 1000

C:\>java ATM 39948872203 deposit 12345678 200

Successfully deposited 200 to account 12345678!

C:\>java ATM 39948872203 withdraw 12345678 50

Successfully withdrew 50 from account 12345678!

C:\>java ATM 39948872203 balance 12345678

The current balance of account 12345678 is 1150

C:\>java ATM 39948872203 statement 12345678 01/10/2018 31/12/2018

The statement for account 12345678 for the period shown is returned and printed out using the accessor methods in the statement and related transaction objects

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!