FenrirsCode

Untitled

Mar 5th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. public class Card {
  2. //making it so there is no Houdini numbers
  3. final int PAIR = 2;
  4. final int SET = 4;
  5. int draw = 0;
  6. //used for generating random numbers
  7. Random ran = new Random();
  8.  
  9. //setting the suit length to 13
  10. final int SUIT_LENGTH = 13;
  11. //declaring where the numbers are for the suit so exp.
  12. // Heart of spades = 14+1 =15 (Ace of Hearts is number 15)
  13. final int SPADE = 1;
  14. final int HEART = 14;
  15. final int DIAMOND = 27;
  16. final int CLUB = 40;
  17. //setting an array of values for 0-12 (really 1-13)
  18. int [] VALUE = { 0,1,2,3,4,5,6,7,8,9,10,11,12 };
  19. //taking the suit numbers from above and adding them to an array
  20. //so i can call on them using value + suit = card.
  21. int [] SUIT = {SPADE,HEART,DIAMOND,CLUB};
  22. //these 4 arrays are set to 2 so I can make it so
  23. // grab 2 numbers from value and one from suit.
  24. int firstPick[] = new int [PAIR];
  25. int secondPick[] = new int [PAIR];
  26. int thirdPick[] = new int [PAIR];
  27. int forthPick[] = new int [PAIR];
  28. //taking the firstPick area
  29.  
  30. int cards [ ] = new int [SET];
  31.  
  32. public void Card()
  33. {
  34. setCard();
  35. }
  36.  
  37.  
  38.  
  39. public void setCard()
  40. {
  41. //this grabs the suit and the value for secondpick array
  42. firstPick[0] = SUIT[ran.nextInt(SUIT.length)];
  43. firstPick[1] = VALUE[ran.nextInt(VALUE.length)];
  44. draw++;
  45. do {
  46. //makes sure that the
  47. secondPick[0] = SUIT[ran.nextInt(SUIT.length)];
  48. secondPick[1] = VALUE[ran.nextInt(VALUE.length)];
  49. draw++;
  50. } while (firstPick[0] != secondPick[0]);
  51.  
  52. do{
  53. thirdPick[0] = SUIT[ran.nextInt(SUIT.length)];
  54. thirdPick[1] = VALUE[ran.nextInt(VALUE.length)];
  55. draw++;
  56. }while (secondPick[0] != thirdPick[0] &&
  57. thirdPick[0] != firstPick[0]);
  58. do{
  59. forthPick[0] = SUIT[ran.nextInt(SUIT.length)];
  60. forthPick[1] = VALUE[ran.nextInt(VALUE.length)];
  61. }while (thirdPick[0] != forthPick[0] &&
  62. forthPick[0] != secondPick[0] &&
  63. forthPick[0] != thirdPick[0]);
  64.  
  65.  
  66. }
  67. public void getCard()
  68. {
  69. cards[0] = firstPick[0] + firstPick[1];
  70. cards[1] = secondPick[0] + secondPick[1];
  71. cards[2] = thirdPick[0] + thirdPick[1];
  72. cards[3] = forthPick[0] + forthPick[1];
  73.  
  74.  
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment