Department of
Computer Science


 

CS 420/520: Object-Oriented Programming

 

Assignment 4: Poker Dice




Set: Thursday 14th February 2013

Due: Tuesday 26th February 2013 at or before midnight.

 

You have been asked to design the user interface for a computer implementation of the game of poker dice.

The rules of the game are as follows.

  • The player starts with 100 points.
  • Each round costs 10 points to play.
  • The player initially rolls a “Hand” consisting of five dice.
  • The payer gets two opportunities to improve the Hand, that is, to obtain a higher score, by re-rolling some or all of the dice.
  • When the player is satisfied with the Hand, or has used up both opportunities to re-roll, the Hand is scored as follows:
Hand of Dice Payout
Two pairs 5
Three-of-a kind 8
Full House (a pair and three-of-a-kind) 12
Four-of-a-kind 15
Straight (1–5 or 2–6) 20
Five of a kind 30
None of the above 0

(A pair is scored when two dice show the same number, three-of-a-kind when three dice show the same number, and so on.) After the hand is scored, the payout is added to the total number of points held by the player

You are required to design an object-oriented model and a Morphic user interface for this game.

The model should contain objects representing the cumulative score, the Hand of five dice, the number of throws that have been taken in the current round (0–3), and the subset of the dice that will be thrown next.

The GUI should consist of a window containing the five dice, the current cumulative score, a way of selecting which dice will be thrown next, a button to throw (the selected subset of the) dice.

You should re-use my Die, DieView, and (if you wish) my Hand code from SqueakSource. (Hand includes a method payout, which implements the above table). The SqueakSource project is the usual one:

MCHttpRepository
location: 'http://www.squeaksource.com/PSUCS520'
user: ' '
password: ' '

The grading rubric is here: (pdf, rtf).  Note that Model-View separation is one of the things that we will grade on.

Groups

I strongly suggest that you do this homework in groups of two. If you have worked in a group before, find a different group. If you have not worked in a group before, try it.

Hints

  • If you haven't done so already, read John Maloney's Morphic Tutorial from Mark Guzdial's book. It is also linked from the Class Schedule page
  • You should be able to build the PokerDiceGameMorph by starting with an empty SystemWindow or RectangleMorph of appropriate size, and embedding in it other Morphs like CheckboxButtonMorph and TextMorph, and of course DieView.
  • To arrange the components in the top level Morph, you can use ProportionalLayout, as we did with the spots on the die, or AlignmentMorphs, as Maloney does in his tutorial with the row of buttons.
  • An alternative (which I tried) to using a checkbox is to make the DieView itself the toggle — click it once to indicate that this die should be thrown, and click it again to indicate that the die should not be thrown. I did this by creating a subclass of DieView.
  • An important feature of Morphic is liveness. Amongst other things, this means that you can have an instance of the Morph that you are building on the screen while you are adding methods to it. So, you can immediately see how its behavior changes. Take advantage of this!

Submitting your work

Email a .mcz version to cs520-hw. In the mail subject include [CS520 Assignment 4] and the names of all members of your group. For example:

Subject: [CS520 Assignment 4] Joe Smith, Karen Chan

Most recently modifed by Andrew P. Black at 15:48 on Friday 17 February 2012