Question: Parallel and Distributed Computing 13. You will write a simulator for a Get a bicycle and Return a bicycle scenario. The idea is that the

Parallel and Distributed Computing

Parallel and Distributed Computing 13. You will write a simulator for a

13. You will write a simulator for a Get a bicycle and Return a bicycle scenario. The idea is that the city places bicycle racks with spaces for 10 bicycles each throughout the city. The citizens can then borrow one of these bicycles and return it later, if there are available empty spots in any of the bicycle racks. There are a few constraints for the bicycle racks: - The number of bicycles in any one rack can never be negative. (l.e. if I want to borrow a bicycle and none are available, then you will have to wait for someone to return a bicycle) - Each rack can hold maximum 10 bicycles (however the citizen will not wait in order to return the bicycle, she will just go to another rack) - A count should be kept to keep track of the number of bicycles for each rack. Write a thread safe Java class (or another appropriate language) for the Rack (i.e. for one rack that can hold 10 bicycles). It should have at least the following methods (you can add additional methods if you need it): - Two constructors: A default constructor (O initial bicycles), and an argument constructor (initializes the number of bicycles) - Method to get a bicycle from the rack - Method to return a bicycle from the rack. - Method to query the current number of bicycles in the rack (i.e. read only)

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!