public class Card implements Comparable{

	final private String suit;
	final private String value;
	private int numericValue = 0;
	final private String[] arr = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};

	public Card(String suit, String value){
		this.suit = suit;
		this.value = value;
		for (int i = 0; i < 13; i++) {
			if (arr[i].equals(value)) {
				numericValue = i + 2;			
			}
		}
//		this.numericValue = arr.indexOf(value) + 2;
	}

	public String getSuit(){
		return suit;
	}

	public String getValue(){
		return value;
	}

	public int getNumericValue(){
		return numericValue;
	}

	public String toString(){
		return value + " of " + suit;
	}

	public int compareTo(Card that){
		return this.numericValue - that.numericValue;
	}
}
    

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.