Last active
March 18, 2016 15:13
-
-
Save jeffprestes/31e7bf16799ed1eea675 to your computer and use it in GitHub Desktop.
Card Array in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.novatrix.cardarray; | |
/** | |
* | |
* @author jprestes | |
*/ | |
public class Cards { | |
//The Card class has 2 arrays: Rank and Suit | |
private final int Ace = 1; | |
private final int Jack = 11; | |
private final int Queen = 12; | |
private final int King = 13; | |
private final int Spades = 1000; | |
private final int Hearts = 2000; | |
private final int Diamonds = 3000; | |
private final int Clubs = 4000; | |
//Cards Index | |
public final int aceIndex = 0; | |
public final int twoIndex= 1; | |
public final int threeIndex= 2; | |
public final int fourIndex= 3; | |
public final int fiveIndex= 4; | |
public final int sixIndex= 5; | |
public final int sevenIndex= 6; | |
public final int eightIndex= 7; | |
public final int nineIndex= 8; | |
public final int jackIndex = 9; | |
public final int queenIndex = 10; | |
public final int kingIndex = 11; | |
public final int spadesIndex = 0; | |
public final int heartsIndex = 1; | |
public final int diamondsIndex = 2; | |
public final int clubsIndex = 3; | |
public int[][] cards = { {Ace, 2, 3, 4, 5, 6, 7, 8, 9, Jack, Queen, King}, | |
{Ace, 2, 3, 4, 5, 6, 7, 8, 9, Jack, Queen, King}, | |
{Ace, 2, 3, 4, 5, 6, 7, 8, 9, Jack, Queen, King}, | |
{Ace, 2, 3, 4, 5, 6, 7, 8, 9, Jack, Queen, King} | |
}; | |
public int[] suit = {Spades, Hearts, Diamonds, Clubs}; | |
public int getValueCard(int paramSuit, int paramCard) { | |
return this.cards[paramSuit][paramCard]*this.suit[paramSuit]; | |
} | |
public static void main(String[] args) { | |
Cards mycards = new Cards(); | |
System.out.println("What's the value of Queen of Spades?"); | |
System.out.println("Value is: " + mycards.getValueCard(mycards.spadesIndex, mycards.queenIndex)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment