Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This lab is on multi-threading,(in java) this is the third and final time I will be posting this question so if you are able to

This lab is on multi-threading,(in java) this is the third and final time I will be posting this question so if you are able to be of assistance , 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

What is M&M Proposition 1? M&M Proposition 2?

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago