CISC181 S2017 CardClass

From class_wiki
Revision as of 01:28, 16 March 2017 by Cer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
 package cisc181.mylab_0;

 // Christopher Rasmussen
 // CISC181, University of Delaware
 // March, 2015

 enum Suit { SPADES, CLUBS, HEARTS, DIAMONDS }
 enum Rank { TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE }

 public class Card {

     Rank rank;
     Suit suit;

     // constructor: specify rank then suit

     Card(Rank r, Suit s) {
         rank = r;
         suit = s;
     }

     // how to print a card
    
     public String toString() {
         return new String(rank + " of " + suit);
     }
 }