Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 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

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

Are robots going to displace all workers? Explain your answer.

Answered: 1 week ago