Advertisement
Guest User

lmao nikhil knanasdfasdlfosadfv

a guest
Feb 24th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. import java.util.*;
  2. public class Proj4 {
  3.  
  4. public static void main(String[] args) {
  5. // TODO Auto-generated method stub
  6. Scanner s = new Scanner(System.in);
  7. String[] suitKey = {"Spades" , "Clubs", "Hearts", "Diamonds"};
  8. 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};
  9. int cNum =0;
  10. int[] value = new int[5];
  11. int[] suit = new int[5];
  12. int nos=0;
  13. int pair=0;
  14. int score=0;
  15. boolean pairFound=false;
  16. int pairValue=30;
  17. Random rand = new Random();
  18.  
  19. while(cNum < 5){
  20. int n = rand.nextInt(52);
  21. if (deck[n] != 20){
  22. value[cNum] = deck[n];
  23. if (n <13){
  24. suit[cNum] = 1;
  25. }
  26. else if (n <26){
  27. suit[cNum]=2;
  28. }
  29. else if (n <39){
  30. suit[cNum]=3;
  31. }
  32. else if (n <52){
  33. suit[cNum]=4;
  34. }
  35. deck[n] =20;
  36. cNum++;
  37. }
  38. }
  39.  
  40.  
  41.  
  42. for (int a=0;a<5;a++){
  43. for (int b=a; b<5;b++){
  44. if(a!=b){
  45. if (value[a] == value[b])
  46. score=2;
  47. }
  48. }
  49. }
  50.  
  51. for(int g = 0; g < value.length - 1; g++){
  52. if(value[g] == pairValue) {
  53. continue;
  54. }
  55. for(int c = g + 1; c < value.length; c++){
  56. if(value[g] == value[c]) {
  57. if(value[g] != pairValue) {
  58. if(pairFound) {
  59. score =3;
  60. }
  61. pairValue = value[g];
  62. pairFound = true;
  63. break;
  64. }
  65. }
  66. }
  67. }
  68.  
  69.  
  70.  
  71. for (int y=0;y<5;y++)
  72. System.out.println(value[y] + " of " + suit[y]);
  73.  
  74.  
  75.  
  76. System.out.println("Shuffling the cards");
  77. System.out.println("Dealing the cards\n");
  78. System.out.println("Here are your five cards...");
  79.  
  80. for (int j=0;j<5;j++){
  81. int sNum = suit[j];
  82. if (value[j] < 11)
  83. System.out.println(value[j]+ " of "+ suitKey[sNum-1]);
  84. else if(value[j] == 11)
  85. System.out.println("Jack of " + suitKey[sNum-1]);
  86. else if(value[j] == 12)
  87. System.out.println("Queen of " + suitKey[sNum-1]);
  88. else if(value[j] == 13)
  89. System.out.println("King of " + suitKey[sNum-1]);
  90. else if(value[j] == 14)
  91. System.out.println("Ace of " + suitKey[sNum-1]);
  92.  
  93.  
  94.  
  95. }
  96. System.out.println("MY score is " + score);
  97.  
  98. }
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement