Question: ( please help with this question for java, please do not hand write :) thank you) Bank holds an array of Accounts. Each Account has

(please help with this question for java, please do not hand write :) thank you)

Bank holds an array of Accounts. Each Account has an associated Client. Each Client can have more than one Account.

An Account class should have 1. a constructor public Account(Client client, int accountNumber, int balance)

2. methods to allow for basic banking operations that are thread-safe, make sure to Log each transaction getBalance() withdraw(int amount) deposit(int amount)

3. method to display account information public String toString()

A Client class should have 1. a constructor public Client(String name) 2. methods to access, modify and display the name

For the purpose of this lab we will simulate the fact that a bank client can have multiple accounts.

A Bank class should have 1. a constructor public Bank(int accountsCount, int clientsCount) Use a random number generator to assign an account ID within the range from 0 to accountsCount.

Use a random number generator to assign a client ID within the range from 0 to clientsCount. Use the name ("Person " + client ID) as the name of the client.

Use a random number generator to assign initial balance from 0 to a 100

2. a method to get a random account public Account getRandomAccount()

3. a method to print the summary of all accounts public void printSummary()

Create a multi-threaded program that emulates the banking operation

1. Create a Bank with 5 accounts and 2 clients 2. Within the main program create three threads of execution each simulating a concurrently operating bank branch or ATM having access to account information. Within each thread have a loop of 10 following operation a. Get a random account b. sleep for random time from 0 to 100 milliseconds c. check account balance and withdraw random (10-200) amount if balance > 0 d. sleep for random time from 0 to 100 milliseconds e. check account balance f. sleep for random time from 0 to 100 milliseconds g. deposit random (10-200) amount

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!