Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PART 4: PRACTICAL PROBLEM SOLVING [15 points] 13. You will write a simulator for a Get a bicycle and Return a bicycle scenario. The idea

image text in transcribed
PART 4: PRACTICAL PROBLEM SOLVING [15 points] 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. (i.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

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

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions