Thanateros

Untitled

Apr 23rd, 2015
231
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Card
  2. {
  3. private final String suit;
  4. private final int value;
  5. private final boolean faceCard;
  6. private final String name;
  7.  
  8. public Card(String theName, String theSuit, int theValue)
  9. {
  10. name = the Name;
  11. suit = the Suit;
  12. value = the Value;
  13.  
  14. if(name.equals("Jack") || name.equals("Queen") || name.equals("King"))
  15. {
  16. faceCard = true;
  17. }
  18. else
  19. {
  20. faceCard = false;
  21. }
  22. }
  23.  
  24. public boolean isFaceCard()
  25. {
  26. return faceCard;
  27. }
  28.  
  29. public String getName()
  30. {
  31. return name;
  32. }
  33.  
  34. public String getSuit()
  35. {
  36. return suit;
  37. }
  38.  
  39. public int getValue()
  40. {
  41. return value;
  42. }
  43.  
  44. public String getColor()
  45. {
  46. if(suit.equals("hearts") || suit.equals("Diamonds"))
  47. {
  48. return "red";
  49. }
  50. else
  51. {
  52. if(suit.equals("Joker"))
  53. {
  54. if(name.equals("#1"))
  55. {
  56. return "red";
  57. }
  58. else
  59. {
  60. return "Black";
  61. }
  62. }
  63. else
  64. {
  65. return "Black";
  66. }
  67. }
  68. }
  69.  
  70. public String toString()
  71. {
  72. if(suit.equals("Joker"))
  73. {
  74. return suit + " " + name;
  75. }
  76. else
  77. {
  78. return name + " of " + suit;
  79. }
  80. }
  81.  
  82. public String getFileName()
  83. {
  84. int cardNumber;
  85. int offset;
  86. int suitVal = 0;
  87.  
  88. switch(name)
  89. {
  90. case "Ace":
  91. offset = 0;
  92. break;
  93.  
  94. case "King":
  95. offset = 1;
  96. break;
  97.  
  98. case "Queen":
  99. offset = 2;
  100. break;
  101.  
  102. case "Jack":
  103. offset = 3;
  104. break;
  105.  
  106. case "Ten":
  107. offset = 4;
  108. break;
  109.  
  110. case "Nine":
  111. offset = 5;
  112. break;
  113.  
  114. case "Eigth":
  115. offset = 6;
  116. break;
  117.  
  118. case "Seven":
  119. offset = 7;
  120. break;
  121.  
  122. case "Six":
  123. offset = 8;
  124. break;
  125.  
  126. case "Five":
  127. offset = 9;
  128. break;
  129.  
  130. case "Four":
  131. offset = 10;
  132. break;
  133.  
  134. case "Three":
  135. offset = 11;
  136. break;
  137.  
  138. case "Two":
  139. offset = 12;
  140. break;
  141.  
  142. default:
  143. offset = 13; //Jokers
  144. }
  145. switch(suit)
  146. {
  147. case "Clubs": case "#1": //Red Joker
  148. suitVal = 1;
  149. break;
  150.  
  151. case "Spades": case "#2": //Black Joker
  152. suitVal = 2;
  153. break;
  154.  
  155. case "Hearts":
  156. suitVal = 3;
  157. break;
  158.  
  159. case "Diamonds":
  160. suitVal = 4;
  161. break;
  162. }
  163. cardNumber = offset * 4 + suitVal;
  164. return cardNumber + ".png";
  165. }
  166. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×