Difference between revisions of "CISC181 S2017 CardClass"

From class_wiki
Jump to: navigation, search
(Created page with " <nowiki> package cisc181.mylab_4; // Christopher Rasmussen // CISC181, University of Delaware // March, 2015 enum Suit { SPADES, CLUBS, HEARTS, DIAMONDS } enum Rank {...")
 
 
Line 1: Line 1:
 
  <nowiki>
 
  <nowiki>
  package cisc181.mylab_4;
+
  package cisc181.mylab_0;
  
 
  // Christopher Rasmussen
 
  // Christopher Rasmussen

Latest revision as of 01:28, 16 March 2017

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