Guest User

Untitled

a guest
May 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. // This is card.java
  2.  
  3. package cardgame;
  4.  
  5. public class Card {
  6.         public static final String [] SUIT_STR =
  7.         {"Diamond", "Club", "Heart", "Spade"};
  8.  
  9.         private int suit; // 0 Diamond, 1 Clubs, 2 Hearts, 3 Spades
  10.         private int number; // 1-10, 11 Jack, 12 Queen, 3 King
  11.  
  12.         public Card(int suit, int number){
  13.             this.suit = suit;
  14.             this.number = number;
  15.         }
  16.  
  17.         public String getDetail() {
  18.             if (number <= 10)
  19.             return(number + " of " + SUIT_STR[suit]);
  20.             else if (number == 11)
  21.                 return("Jack of " + SUIT_STR[suit]);
  22.             else if (number == 12)
  23.                 return("Queen of " + SUIT_STR[suit]);
  24.             else
  25.                 return("King of " + SUIT_STR[suit]);
  26.         }
  27. }
Add Comment
Please, Sign In to add comment