ผลต่างระหว่างรุ่นของ "01219343/unit/poker"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
แถว 14: แถว 14:
 
* <code>hasSameRank</code>
 
* <code>hasSameRank</code>
 
* <code>hasSameSuit</code>
 
* <code>hasSameSuit</code>
* implements <code>Comparable&lt;Card&gt;</code>
+
* The class should implement interface <code>Comparable&lt;Card&gt;</code> so that we can easily sort the cards.  Add that interface to the class and implement a public method <code>int compareTo(Card c)</code>.
  
 
== Hand ==
 
== Hand ==
  
 
Use [https://en.wikipedia.org/wiki/List_of_poker_hands|this reference of poker hands] from wikipedia.
 
Use [https://en.wikipedia.org/wiki/List_of_poker_hands|this reference of poker hands] from wikipedia.

รุ่นแก้ไขเมื่อ 16:20, 24 มกราคม 2556

Follow the TDD steps to write these classes.

Card

A card has a rank (A,1,...,9,10,J,Q,K) and a suit (S,H,D,C) (see suit).

Implement class Card that supports the following methods:

  • Construction with rank and suit as strings. (This might not be an efficient way to represent ranks and suits, but it simplifies the exercise.) For example:
Card card = new Card("10","S");
  • Getters: getRank and getSuit
  • hasSameRank
  • hasSameSuit
  • The class should implement interface Comparable<Card> so that we can easily sort the cards. Add that interface to the class and implement a public method int compareTo(Card c).

Hand

Use reference of poker hands from wikipedia.