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 2.51 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. for (int a=0;a<5;a++){
  41. for (int b=a; b<5;b++){
  42. if(a!=b){
  43. if (value[a] == value[b])
  44. score=2;
  45. }
  46. }
  47. }
  48. /*for (int a=0;a<5;a++){
  49. for (int b=a;b<5;b++){
  50. if(a!=b){
  51. if (value[a]==value[b]&& value[b]==value[a-1])
  52.  
  53.  
  54.  
  55. }
  56. }
  57. }
  58. */
  59.  
  60.  
  61. for(int g = 0; g < value.length - 1; g++){
  62. if(value[g] == pairValue) {
  63. continue;
  64. }
  65. for(int c = g + 1; c < value.length; c++){
  66. if(value[g] == value[c]) {
  67. if(value[g] != pairValue) {
  68. if(pairFound) {
  69. score =3;
  70. }
  71. pairValue = value[g];
  72. pairFound = true;
  73. break;
  74. }
  75. }
  76. }
  77. }
  78.  
  79.  
  80.  
  81. for (int y=0;y<5;y++)
  82. System.out.println(value[y] + " of " + suit[y]);
  83.  
  84. value = {9, 7, 9, 2, 7};
  85. suit = {1,2,3,4,1};
  86.  
  87. System.out.println("Shuffling the cards");
  88. System.out.println("Dealing the cards\n");
  89. System.out.println("Here are your five cards...");
  90.  
  91. for (int j=0;j<5;j++){
  92. int sNum = suit[j];
  93. if (value[j] < 11)
  94. System.out.println(value[j]+ " of "+ suitKey[sNum-1]);
  95. else if(value[j] == 11)
  96. System.out.println("Jack of " + suitKey[sNum-1]);
  97. else if(value[j] == 12)
  98. System.out.println("Queen of " + suitKey[sNum-1]);
  99. else if(value[j] == 13)
  100. System.out.println("King of " + suitKey[sNum-1]);
  101. else if(value[j] == 14)
  102. System.out.println("Ace of " + suitKey[sNum-1]);
  103.  
  104.  
  105.  
  106. }
  107. System.out.println("MY score is " + score);
  108.  
  109. }
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement