CISC181 S2017 CardClass

From class_wiki
Revision as of 17:42, 3 February 2017 by Cer (talk | contribs) (Created page with " <nowiki> package cisc181.mylab_4; // Christopher Rasmussen // CISC181, University of Delaware // March, 2015 enum Suit { SPADES, CLUBS, HEARTS, DIAMONDS } enum Rank {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
 package cisc181.mylab_4;

 // 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);
     }
 }