Guest User

Untitled

a guest
Jan 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package carddeckapp;
  6.  
  7. import java.awt.Color;
  8. import java.util.Arrays;
  9.  
  10. /**
  11. *
  12. * @author seed419
  13. */
  14. public class Deck {
  15.  
  16. static Card[] deck;
  17. int[] number = {1,2,3,4,5,6,7,8,9,10,11,12,13};
  18.  
  19. public Deck(){
  20. }
  21.  
  22. public void loadNewDeck(){
  23. int counter = 0;
  24. deck = new Card[52];
  25. for(int x : number){
  26. deck[counter] = new Card(x, Suit.CLUBS, Color.BLACK);
  27. counter++;
  28. }
  29. for(int y : number){
  30. deck[counter] = new Card(y, Suit.DIAMONDS, Color.RED);
  31. counter++;
  32. }
  33. for(int z : number){
  34. deck[counter] = new Card(z, Suit.SPADES, Color.BLACK);
  35. counter++;
  36. }
  37. for(int w: number){
  38. deck[counter] = new Card(w, Suit.HEARTS, Color.RED);
  39. counter++;
  40. }
  41. }
  42.  
  43. public void printDeckNormally(){
  44. for(int counter = 0; counter < deck.length; counter++){
  45. Card x = deck[counter];
  46. System.out.println(x.getColor() + " " + x.getValue() + " of " + x.getSuit());
  47. }
  48. System.out.println();
  49. }
  50.  
  51. public void printDeck(){
  52. int counter = 0;
  53. Arrays.sort(deck);
  54. for(int j = 0; j <13; j++){
  55. Card x = deck[counter];
  56. System.out.print(x.getColor() + " " + x.getValue() + " of " + x.getSuit() + " ");
  57. counter++;}
  58. System.out.println();
  59. for(int j = 0; j <13; j++){
  60. Card x = deck[counter];
  61. System.out.print(x.getColor() + " " + x.getValue() + " of " + x.getSuit() + " ");
  62. counter++;}
  63. System.out.println();
  64. for(int j = 0; j <13; j++){
  65. Card x = deck[counter];
  66. System.out.print(x.getColor() + " " + x.getValue() + " of " + x.getSuit() + " ");
  67. counter++;}
  68. System.out.println();
  69. for(int j = 0; j <13; j++){
  70. Card x = deck[counter];
  71. System.out.print(x.getColor() + " " + x.getValue() + " of " + x.getSuit() + " ");
  72. counter++;}
  73. System.out.println();
  74. }
  75.  
  76. public void shuffle(){
  77. for(int counter=0;counter<deck.length;counter++){
  78. for(int temp4=0;temp4<100;temp4++){
  79. double rand2 = Math.random();
  80. int rand = (int) (rand2 * 50) +1;
  81.  
  82. Card temp = deck[rand];
  83. Card temp2 = deck[counter];
  84. deck[counter] = temp;
  85. deck[rand] = temp2;
  86. }
  87. }
  88. }
  89.  
  90.  
  91. }
Add Comment
Please, Sign In to add comment