CISC181 S2019 Lab4

From class_wiki
Revision as of 11:36, 13 March 2019 by Cer (talk | contribs) (Instructions)
Jump to: navigation, search

Preliminaries

  • Make a new project with n = 4 (following these instructions)
  • Name your main class "Lab4" (when creating a new module in the instructions above, in the Java class name field)
  • Remember that this week you can choose a partner, or work alone. No partners will be assigned

Instructions

Suppose you want to write a video poker simulator based on the provided Card , Deck, and Hand classes. See "The Game" section here for the rules, in particular the "Jacks or Better" variant. In short, let's say you bet $1 per hand. For each hand you are given 5 random cards, and you can choose from 1 to 5 of them to replace. Depending on what you have (a pair, two pairs, three of a kind, flush, etc.), you get a payout based on the odds. We will use the following payout chart:

Poker payouts.png


This will not be visual -- no Swing this week!

Obviously, a core function would be to compare two hands and determine which one is better.

In this lab you will write a Comparator class ByHandValue to compare hands in 5-card draw Poker. The comparison function will be int compare(ArrayList<Card> H1, ArrayList<Card> H2), where a return value < 0 indicates that H1 would lose to H2, a return value > 0 means that H1 would beat H2, and a return value of 0 means H1 and H2 are "tied." You must use the Card class provided -- do not make your own.

The ranking of hands is detailed here. Assume that cards come from a standard 52-card deck with no wildcards, and aces can be high or low. This will be a complicated function -- please make it as modular as possible by calling other support functions.


We will grade your lab strictly by how many of the N unit tests in our grading suite are passed. Since you can get compare() right 1/3 of the time just by chance, your lab score will be determined by a linear map from [N/3, N] tests passed to a score of [1, 4].

Submission

Submit your ByHandValue.java on Canvas (be sure to add your name to any files you create or change). Do NOT submit Lab4.java.