Multithreading and Synchronization. The Cookie Monsters Game.

CIS470 Assignment 4
Multithreading and Synchronization
Due: Th. Nov 4th
The Cookie Monsters Game
Create an Android application to visualize
the combat between two Cookie-Monsters
competing for the Most voracious and
polite cookie eater of the world contest.
Each monster spends its life eating and
resting. In this contest a jar full of cookies
will be presented to the monsters. Only
one of them is allowed to grab cookies
from the jar at any single time. Once a
monster’s hand is in the jar it will randomly
take any number of the existing cookies,
varying between zero and all of them. Then
the monster will consume the cookies at a
random speed not to exceed 5 seconds.
As soon as a monster has finished eating,
the cycle is repeated again. The other
monster does exactly the same.
The cookie supply is not infinite. Grandma
Monster is continuously baking at most 10
new cookies every 5 seconds. All new
cookies are added to the jar. Please notice
that Grandma could take breaks, during
those periods no new cookies are made.
The contest’s winner is determined as
either (1) the first monster to eat 100
cookies, or (2) the monster that has eaten
the most cookies in two minutes.
Design Specifications
Produce a UI similar to the wireframe design suggested above. The horizontal progress bars indicate the
current amount of cookies eaten by each monster (0 to 100). The circular progress bar simply rotates
until the game is over. The simulation clock is updated every second of the game. Clicking the “Start
over” button resets all variables and triggers a new simulation. The “Cancel” button stops all threads
freezing the screen.