Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.13 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.*;
  3. public class Proj4 {
  4.  
  5. /*
  6. You must include the following statements below in the code
  7. that you submit to get full credit. Use hardcoded values
  8. to test each of the possible hands.
  9.  
  10. Project must work if any of the hardcoded arrays are uncomment
  11. with your random card generator portion comment out)
  12. GTAs will use these values to test your program
  13.  
  14. Assume suits are numbered 1-4
  15. Assume 11=Jack, 12=Queen 13=King 14=Ace
  16. */
  17.  
  18. // Used for testing different hands ... comment out dealing cards
  19. // and initialize when declared
  20.  
  21. // Royal Flush
  22. //int[] value = {10, 12, 14, 13, 11};
  23. //int[] suit = {1,1,1,1,1};
  24.  
  25. // Straight Flush
  26. //int[] value = {9, 7, 8, 6, 5};
  27. //int[] suit = {1,1,1,1,1};
  28.  
  29. // 4 of kind
  30. //int[] value = {9, 7, 9, 9, 9};
  31. //int[] suit = {1,2,3,4,1};
  32.  
  33. // Full House
  34. //int[] value = {9, 7, 9, 7, 9};
  35. //int[] suit = {1,2,3,4,1};
  36.  
  37. // Flush
  38. //int[] value = {9, 10, 8, 6, 5};
  39. //int[] suit = {1,1,1,1,1};
  40.  
  41. // Straight
  42. //int[] value = {9, 7, 8, 6, 5};
  43. //int[] suit = {1,2,4,3,1};
  44.  
  45. // 3 of kind
  46. //int[] value = {9, 7, 9, 2, 9};
  47. //int[] suit = {1,2,3,4,1};
  48.  
  49. // Two Pair
  50. //int[] value = {9, 7, 9, 2, 7};
  51. //int[] suit = {1,2,3,4,1};
  52.  
  53. // One Pair
  54. //int[] value = {9, 7, 8, 2, 7};
  55. //int[] suit = {1,2,3,4,1};
  56.  
  57. // High Card (Ace)
  58. //int[] value = {9, 7, 8, 14, 11};
  59. //int[] suit = {1,2,3,4,1};
  60.  
  61.  
  62.  
  63. // } // end main
  64. // } // end class
  65.  
  66.  
  67. public static void main(String[] args) {
  68. // TODO Auto-generated method stub
  69.  
  70. Scanner sc = new Scanner(System.in);
  71.  
  72. System.out.println("**Welcome to the 2017 Las Vegas Poker Festival!**");
  73. System.out.println("Application developed by Yoav Bittan");
  74.  
  75. String[] suitKey = {"Spades" , "Clubs", "Hearts", "Diamonds"};
  76. int[] deck = {2,3,4,5,6,7,8,9,10,11,12,13,14,2,3,4,5,6,7,8,9,10,11,12,13,14,2,3,4,5,6,7,8,9,10,11,12,13,14,2,3,4,5,6,7,8,9,10,11,12,13,14};
  77. int val = 0;
  78. String strength = "none";
  79. int[] value = new int[0];
  80. int[] p = new int[0];
  81. int[] s = new int[0];
  82. int[] suit = new int[0];
  83. Random rand = new Random();
  84.  
  85. while(val < 5){
  86. int n = rand.nextInt(52);
  87. if (deck[n] != 20){
  88. value[val] = deck[n];
  89. if (n <13){
  90. suit[val] = 1;
  91. }
  92. else if (n <26){
  93. suit[val]=2;
  94. }
  95. else if (n <39){
  96. suit[val]=3;
  97. }
  98. else if (n <52){
  99. suit[val]=4;
  100. }
  101. deck[n] = 20;
  102.  
  103. val++;
  104. }
  105. }
  106.  
  107. //for (int p=0;p<5;p++){
  108. //if (value[p])
  109. //}
  110.  
  111.  
  112.  
  113. // for (int y=0;y<5;y++)
  114. // System.out.println(value[y] + " of " + suit[y]);
  115.  
  116.  
  117.  
  118. System.out.println("Shuffling the cards");
  119. System.out.println("Dealing the cards\n");
  120. System.out.println("Here are your five cards...");
  121.  
  122. for (int j=0;j<5;j++){
  123. int sNum = suit[j];
  124. if (value[j] < 11)
  125. System.out.println(value[j]+ " of "+ suitKey[sNum-1]);
  126. else if(value[j] == 11)
  127. System.out.println("Jack of " + suitKey[sNum-1]);
  128. else if(value[j] == 12)
  129. System.out.println("Queen of " + suitKey[sNum-1]);
  130. else if(value[j] == 13)
  131. System.out.println("King of " + suitKey[sNum-1]);
  132. else if(value[j] == 14)
  133. System.out.println("Ace of " + suitKey[sNum-1]);
  134.  
  135.  
  136. // high card
  137. if (value[1] > value[2]){
  138. if (value[1] > value[3]){
  139. if(value[1] > value[4]){
  140. if(value[1] > value[0]){
  141. strength = ("High card" + value[1]);
  142. }
  143. }
  144. }
  145. }
  146.  
  147.  
  148.  
  149. if (value[2] > value[1]){
  150. if (value[2] > value[3]){
  151. if(value[2] > value[4]){
  152. if(value[2] > value[0]){
  153. strength = ("High card" + value[2]);
  154. }
  155. }
  156. }
  157. }
  158.  
  159.  
  160.  
  161. if (value[3] > value[1]){
  162. if (value[3] > value[2]){
  163. if(value[3] > value[4]){
  164. if(value[3] > value[0]){
  165. strength = ("High card" + value[3]);
  166. }
  167. }
  168. }
  169. }
  170.  
  171.  
  172.  
  173. if (value[4] > value[1]){
  174. if (value[4] > value[2]){
  175. if(value[4] > value[3]){
  176. if(value[4] > value[0]){
  177. strength = ("High card" + value[1]);
  178. }
  179. }
  180. }
  181. }
  182.  
  183.  
  184. if (value[0] > value[1]){
  185. if (value[0] > value[2]){
  186. if(value[0] > value[3]){
  187. if(value[0] > value[4]){
  188. strength = ("High card" + value[1]);
  189. }
  190. }
  191. }
  192. }
  193. // all the pairs
  194.  
  195. if (value[1] == p[2]){
  196. strength = "pair";}
  197.  
  198. if (value[1] == p[3]){
  199. strength = "pair";}
  200.  
  201. if (value[1] == p[4]){
  202. strength = "pair";}
  203.  
  204. if (value[1] == p[0]){
  205. strength = "pair";}
  206. /////////////////
  207. if (value[2] == p[1]){
  208. strength = "pair";}
  209.  
  210. if (value[2] == p[3]){
  211. strength = "pair";}
  212.  
  213. if (value[2] == p[4]){
  214. strength = "pair";}
  215.  
  216. if (value[2] == p[0]){
  217. strength = "pair";}
  218. /////////////////
  219. if (value[3] == p[1]){
  220. strength = "pair";}
  221.  
  222. if (value[3] == p[2]){
  223. strength = "pair";}
  224.  
  225. if (value[3] == p[4]){
  226. strength = "pair";}
  227.  
  228. if (value[3] == p[0]){
  229. strength = "pair";}
  230. ////////////////////
  231. if (value[4] == p[1]){
  232. strength = "pair";}
  233.  
  234. if (value[4] == p[2]){
  235. strength = "pair";}
  236.  
  237. if (value[4] == p[3]){
  238. strength = "pair";}
  239.  
  240. if (value[4] == p[0]){
  241. strength = "pair";}
  242. //////////////////
  243. if (value[0] == p[1]){
  244. strength = "pair";}
  245.  
  246. if (value[0] == p[2]){
  247. strength = "pair";}
  248.  
  249. if (value[0] == p[3]){
  250. strength = "pair";}
  251.  
  252. if (value[0] == p[4]){
  253. strength = "pair";}
  254.  
  255. ///
  256. // 2 pair
  257.  
  258.  
  259. System.out.println(strength);
  260.  
  261. }
  262. }
  263.  
  264. //
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement