Chris Pollett >
Old Classes >
PIC20B

   ( Print View )

Enrollment info

Course Info: Homework Assignments: Practice Exams: PIC:
                            












HW#3 --- last modified January 16 2019 00:35:19..

Solution set.

Due date: May 9 10:30pm.
=========

Files to be submitted: p20bhw3file1.zip -- zip file of all the source
======================                     files and gifs used in your
                                           program should have a README
					   file saying how to compile
                                           your code

HW3 Purpose:  To gain familiarity with threads and exception handling.
============

Specification:
==============
For this assignment your goal is to make a slot machine simulator application
which is as realistic as possible. The writers of the top three simulators will
be given two bonus points which will be added to their score after final
curving. The simulator aplication must be written subject to the following
constraints, but you are otherwise free to your exercise imagination in doing
this assignment. The first constraint is that the slot machine can pay out
at most $2.00 total from when the application is first run and that if
the slot machine pays out it pays out at least $.25 a time.
The probability of a pay-out should be at least 20% so the grader
can test this feature. When $2.00 has been exceeded your program must throw a
TiltException (which is an Exception class that you write). This Exception
should be caught and "Machine out of money" should be written to System.err.
The second constraint concerns the animations of the reels of the slot machine.
Each reel should have a Thread associated with it. You should not directly
extend the Thread class but use the Runnable interface instead.
These Threads control when a reel stops spinning. (The actually spinning of
the reel can be handled by using a Timer). Except for the Thread for the
rightmost reel these Threads operate by going into a wait state until
notified by the Thread for the reel to its right that the reel to the right has
stopped spinning. At which point the Thread sleeps for a random amount of
time, wakes up, stops its reel's animation then notifies the thread to the
left that it has stopped. Or if there is no reel to the left it notifies a
payout Thread. The Thread for the rightmost reel is almost the same except
that it doesn't initially go into a wait state but instead immediately
sleeps for some random amount of time.


Point Breakdown for HW3
=======================
Code documentation......................1pt
TiltException class.....................1pt
Payout and total payouts satisfy the
   constraint above.....................1pt
try-catch for TiltException as above....1pt
Mechanism to start reels running works..1pt
Reel animation works....................1pt
Runnable interface implemented..........1pt
Appropriate Threads go into wait
     states initially...................1pt
When a reel stopped appropriate Thread
 notified and that thread acts as
 described above........................1pt
All reels eventually stop and there is a
    payout..............................1pt

Total..................................10pts