package com.abl.PlayingCards; import java.util.Vector; //CardLabels: /** types of marks that a Card can have; thus, defines/makes the type/style of DeckOfCards @version 11/29/2000 @author I made this. -- prie, 5/8/99 */ final public class CardLabels { private String[] faces, suits; private int jokers, combinations; public CardLabels() { //Solitaire defaults: 52 cards, ace-low, plus 2 jokers faces = new String[] { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" }; suits = new String[] { "Clubs", "Diamonds", "Hearts", "Spades" }; jokers = 2; combinations = jokers + faces.length * suits.length; } public CardLabels(String[] optFaces, String[] optSuits, int numJokers) { //for user-defined labels faces = optFaces; suits = optSuits; jokers = numJokers; combinations = jokers + faces.length * suits.length; } Vector makeCards() { //make all combinations: slap labels on cards Vector deck = new Vector(combinations); int rank = 1; for (int j = 0; j < suits.length; j++) for (int i = 0; i < faces.length; i++) deck.addElement( new Card(faces[i], suits[j], rank++) ); //assign jokers negative faceValues and identical ranks for (int k = 1; k <= jokers; k++) deck.addElement( new Card(Integer.toString(-k), "Joker", rank) ); return deck; } }