import java.util.Arrays; /** * @author Tina * Created on: 2/16/17 * File name: Card.java * This class contains functions to * specify the value and suit of the card that is being created. */ public class Card { private static int[] cards = new int[52]; public enum Deck{ AceofSpades,TwoofSpades,ThreeofSpades,FourofSpades,Fiveofspades, SixofSpades,SevenofSpades,EightofSpades,NineofSpades,TenofSpades, JackofSpades,QueenofSpades,KingofSpades, AceofClubs,TwoofClubs,ThreeofClubs,FourofClubs,FiveofClubs, SixofClubs,SevenofClubs,EightofClubs,NineofClubs,TenofClubs, JackofClubs,QueenofClubs,KingofClubs, AceofHearts,TwoofHearts,ThreeofHearts,FourofHearts,FiveofHearts, SixofHearts,SevenofHearts,EightofHearts,NineofHearts,TenofHearts, JackofHearts,QueenofHearts,KingofHearts, AceofDiamonds,TwoofDiamonds,ThreeofDiamonds,FourofDiamonds, FiveofDiamonds,SixofDiamonds,SevenofDiamonds,EightofDiamonds, NineofDiamonds,TenofDiamonds,JackofDiamonds,QueenofDiamonds, KingofDiamonds } int current_card_to_play; int[] playerCards; //shuffle() to shuffle the deck into a random order. public int[] shuffle(){ int val = 0; for(Deck d: Deck.values()){ cards[val] = d.ordinal(); val++; } for(int i = 51; i >= 0; i--){ int rand = (int)(Math.floor(Math.random() * (i+1))); int temp = cards[i]; cards[i] = cards[rand]; cards[rand] = temp; } // for(Deck d: Deck.values()){ // System.out.println(d.toString()); // } return cards; } public int assignCards(int players){ int card_total = 0; if(players == 2){ card_total= 26; }else if(players == 4){ card_total = 13; } return card_total; } public int[] displayCards(int start, int end){ for(int i = start; i< end; i++){ //if(cards[i] != -1){ System.out.print(cards[i] + ", "); //} } System.out.println(); playerCards = Arrays.copyOfRange(cards, start, end); return playerCards; } /** * @param * @return */ public int[] getActualCardsToBePlayed(int current_card_to_play) { this.current_card_to_play = current_card_to_play; // TODO Auto-generated method stub int[] actualCardsToBePlayed = null; if(current_card_to_play == 0)//Aces actualCardsToBePlayed = new int[] {0,13,26,39}; else if(current_card_to_play == 1)//Twos actualCardsToBePlayed = new int[] {1,14,27,40}; else if(current_card_to_play == 2)//Threes actualCardsToBePlayed = new int[] {2,15,28,41}; else if(current_card_to_play == 3)//Fours actualCardsToBePlayed = new int[] {3,16,29,42}; else if(current_card_to_play == 4)//Fives actualCardsToBePlayed = new int[] {4,17,30,43}; else if(current_card_to_play == 5)//Sixes actualCardsToBePlayed = new int[] {5,18,31,44}; else if(current_card_to_play == 6)//Sevens actualCardsToBePlayed = new int[] {6,19,32,45}; else if(current_card_to_play == 7)//Eights actualCardsToBePlayed = new int[] {7,20,33,46}; else if(current_card_to_play == 8)//Nines actualCardsToBePlayed = new int[] {8,21,34,47}; else if(current_card_to_play == 9)//Tens actualCardsToBePlayed = new int[] {9,22,35,48}; else if(current_card_to_play == 10)//Jacks actualCardsToBePlayed = new int[] {10,23,36,49}; else if(current_card_to_play == 11)//Queens actualCardsToBePlayed = new int[] {11,24,37,50}; else if(current_card_to_play == 12)//Kings actualCardsToBePlayed = new int[] {12,25,38,51}; return actualCardsToBePlayed; } // public static void main(String[] args) { // shuffle(); // } // // }