rendered paste bodypackage redcrosspoker;/** * @author Andre Lægreid * */public class Card implements Comparable<Card> { private String suit; private int face; public Card(String suit, int face) { this.suit = suit; this.face = face; } public String getSuit() { return this.suit; } public int getFace() { return this.face; } private int getFaceValue() { return (this.face == 1 ? 14 : this.face); } public int compareTo(Card card) { if(this.face == card.face) { return 0; } else { return (this.getFaceValue() < card.getFaceValue() ? -1 : 1); } } public String toString() { return this.suit+this.face; }}package redcrosspoker;import java.util.ArrayList;import java.util.Collections;/** * @author Andre Lægreid * */public class CardDeck { private ArrayList<Card> cards; public CardDeck() { cards = new ArrayList<Card>(); String[] suits = {"S", "H", "D", "C"}; for (int i=0; i < suits.length; i++) { for (int j=1; j <= 13; j++) { cards.add(new Card(suits[i], j)); } } } public CardDeck(boolean shuffle) { this(); if (shuffle) shuffle(); } private void shuffle() { Collections.shuffle(this.cards); } public Card getCard(int index) { return (index < 0 || index > size() ? null : cards.get(index)); } public int size() { return this.cards.size(); }}