Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package carddeckapp;
- import java.awt.Color;
- import java.util.Arrays;
- /**
- *
- * @author seed419
- */
- public class Deck {
- static Card[] deck;
- int[] number = {1,2,3,4,5,6,7,8,9,10,11,12,13};
- public Deck(){
- }
- public void loadNewDeck(){
- int counter = 0;
- deck = new Card[52];
- for(int x : number){
- deck[counter] = new Card(x, Suit.CLUBS, Color.BLACK);
- counter++;
- }
- for(int y : number){
- deck[counter] = new Card(y, Suit.DIAMONDS, Color.RED);
- counter++;
- }
- for(int z : number){
- deck[counter] = new Card(z, Suit.SPADES, Color.BLACK);
- counter++;
- }
- for(int w: number){
- deck[counter] = new Card(w, Suit.HEARTS, Color.RED);
- counter++;
- }
- }
- public void printDeckNormally(){
- for(int counter = 0; counter < deck.length; counter++){
- Card x = deck[counter];
- System.out.println(x.getColor() + " " + x.getValue() + " of " + x.getSuit());
- }
- System.out.println();
- }
- public void printDeck(){
- int counter = 0;
- Arrays.sort(deck);
- for(int j = 0; j <13; j++){
- Card x = deck[counter];
- System.out.print(x.getColor() + " " + x.getValue() + " of " + x.getSuit() + " ");
- counter++;}
- System.out.println();
- for(int j = 0; j <13; j++){
- Card x = deck[counter];
- System.out.print(x.getColor() + " " + x.getValue() + " of " + x.getSuit() + " ");
- counter++;}
- System.out.println();
- for(int j = 0; j <13; j++){
- Card x = deck[counter];
- System.out.print(x.getColor() + " " + x.getValue() + " of " + x.getSuit() + " ");
- counter++;}
- System.out.println();
- for(int j = 0; j <13; j++){
- Card x = deck[counter];
- System.out.print(x.getColor() + " " + x.getValue() + " of " + x.getSuit() + " ");
- counter++;}
- System.out.println();
- }
- public void shuffle(){
- for(int counter=0;counter<deck.length;counter++){
- for(int temp4=0;temp4<100;temp4++){
- double rand2 = Math.random();
- int rand = (int) (rand2 * 50) +1;
- Card temp = deck[rand];
- Card temp2 = deck[counter];
- deck[counter] = temp;
- deck[rand] = temp2;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment