Question
Assuming that I have a cheese shop that has mouses problem. I would like to set up a list of traps to remove mouses. Idon't
Assuming that I have a cheese shop that has mouses problem.
I would like to set up a list of traps to remove mouses. Idon't know how many traps I will need, so I need to design a simulation for it using Java Programming.
In this simulation, A cheese machine which can generate 10 grams of cheese to a cheese container every 2 seconds. In addition, there are X number of mouses and Y traps.
Every second, a mouse will consume 1-3 grams from the cheese container. If cheese container does not contain any cheese, the mouse will wait for it. Before a mouse eating cheese, it will have 50% chance to get caught by a trap. Each trap can only catch one rat.
The trap can only be available again when the shop owner removes the caught mouse. Every 5 seconds, the shop owner will check the traps and remove all the caught mouses. Finally, after all the mouses are removed from the shop, your simulation needs to print out the total loss of cheese in grams. More details: Assume that a mouse would like to consume 3 grams of cheese, however, the container only has 1 gram left, then the mouse can only consume 1 gram of it. Each mouse has an integer number representing the id of the mouse. e.g., mouse-1 or mouse-3. Please print the divider "============" when the owner removed mouses for better readability. The cheese container starts with a default number of cheese.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started