import java.util.*; public final class AcesHighAlgorithms { private Scanner scanner = new Scanner(System.in); private final static int kNumPiles = 4; /* The four piles of cards */ private Stack[] cardPiles; /* The deck of 52 playing cards */ private Stack deck; /** Construct the application */ @SuppressWarnings("unchecked") public AcesHighAlgorithms() { // Initialize the card piles cardPiles = (Stack[]) new Stack[kNumPiles]; } /** Entry point for the application. * @param args ignored */ public static void main(String[] args) { // Instantiate this class // IF a command line argument was given THEN // Create deck from a single string of 52 card names with NO embedded blanks // ELSE // create a random deck // END IF // run the game } /** Play the game until the user quits or the game is over. * @author Edgard Arroliga * @author Jacob BOyles */ public void run() { //INIT 4 Piles //DISPLAY Welcome Message //Deal 4 cards //DISPLAY Table //WHILE Game has not ended && user has not quit //DISPLAY PROMPT //GET Move input from player //CASE player input OF //condition D: Deal 4 cards //condition Mx: //IF can move THEN //move card from pile "x" //END IF //condition Q: //SET quit condition to true //condition default: //IF can discard from pile number input THEN //remove top of the pile number input //END IF //END CASE //PRINT table //END WHILE //DISPLAY score } /** Create the empty card piles * @author Dat Tran * @author Jonathan Molina */ public void initPiles() { // INIT cardPiles to an array of stacks of integers with kNumPiles length } /** Deal one card from the deck onto each pile. * @author Eric LaBouve * @author Helen Hwang * @return false if unable to deal all four cards. */ public boolean dealFour() { //Make a Counter set to zero //WHILE we have not dealt 4 cards and the deck is not empty //Deal Card on to pile of counter //Increment counter //ENDWHILE //RETURN true IF counter == 4, ELSE return false return true; } //Author: Javon Negahban public int dealCard() { // RETURN pop from deck return 0; } /** See if the card on top of pileNum can be moved. * @author Austin Robarts * @author Sonia Tomas * @param pileNum the number of the pile selected for discard. * @pre 0 <= pileNum < 4 * @return the available pilenumber, if it exists, otherwise -1 */ public int canMove(int pileNum) { //SET returnIndex to -1 //WHILE there is still a pile left // IF pile is empty // SET returnIndex to the current pile index // ENDIF // INCREMENT to next pile //ENDWHILE //return returnIndex return 0; } // //public void discard(int pile) //{ // IF you can discard a card from the specified pile AND the pile number is valid THEN // // Discard a card from the card pile // //} /** See if the card on top of pileNum can be discarded. * @param pileNum the number of the pile selected for discard. * @pre 0 <= pileNum < 4 * @return true if there exists another visible card of the same suit * with a higher rank than the top card of selected pile. * @author Fina Beauchamp * @author Myra Lukens */ public boolean canDiscard(int pileNum) { //peek @ top card in stack (pileNum) //FOR all piles //peek at top card //IF that card is of the same suit and larger //than the top card in stack pileNum //return true //return false return true; } /** * @author Kevin Pham * @author Colin Adams */ /** Remove the top card from selected pile. * @param pileNum selected pile * @pre cardPiles[pileNum].size() > 0 */ public void removeTop(int pileNum) { //IF canDiscard pileNum THEN //pop card from top of stack } /** Move the top card from selected pile to an empty pile. * @param pileNum selected pile * @param emptyPile the pile number of the empty pile * @pre canMove(pileNum) > -1 */ public void moveTop(int pileNum) { // IF canMove pileNum THEN //pop card from stack //push card onto empty stack given by canMove } public boolean isEmpty() { // RETURN deck size is 0 return true; } /** Accessor to the rank symbol of a card. * @author Nate Diamond * @param card the card for which the rank is extracted */ public char getRank(int card) { // Convert the card into a symbol for its rank and return the symbol //return symbol return ' '; } /** Accessor to the suit symbol of a card. * @author Nate Diamond * @param card the card for which the suit is extracted */ public char getSuit(int card) { // Convert the card into a symbol for its suit and return the symbol //return symbol return ' '; } /** Compute the score; how many cards are left on the table. * @return the table score. * @author Nathan Lemay * @author Jason Krein */ public int getScore() { //RETURN Total cards in deck minus cards on table return 0; } /** Does this card have the same suit and a lower rank * than Other card. * @param other card to be compared to * @return true if this card is less than other * @author Sean Bayley * @author Kyle Reis */ public boolean lessThan(int card1, int card2) { //IF card1 is the same suit as card2 //IF card1 is less than card2 //RETURN true //ELSE //RETURN false; return true; } /** Perform move to empty spot. * @param desired pile from which to move the top card */ public void move(int pile) { /* * If pile is invalid (pile is not 0 to 3) * Print error message * Else if there is an empty pile * Take top card of desired pile * Move card to the empty pile */ } public void createDeckFromString(String deckString) { //FOR each two characters in desckString //create card from the two characters //push the card to the top of the deckk //ENDFOR } /** Construct a deck of cards in random order. @author Michael Murphy */ public void createRandomDeck() { // java.util.LinkedList deck = new java.util.LinkedList(); // FOR EACH NUMBER i FROM 0 TO 52 // { // ADD THE NUMBER i TO THE deck // } // Call Collections.shuffle with deck; } public void printTable() { //NEW card stack, pileCopy //NEW card stack, tempPile //FOR each cardPiles, 0 through kNumPiles - 1, defined by index //SET pileCopy to cardPile[index] //WHILE pileCopy is not empty //Pop the top of stack and push to tempPile //END for //WHILE tempPile is not empty //Pop the top of stack and print to terminal //END for //END for } /** Return a printable representation of this card. * This implementation returns a 2 letter abbreviation. * @author Chase Dreszer * @return abbrevation of the card, e.g., "2C" */ public String getCard(int card) { //Convert the card into a rank //Convert the card into a suit // RETURN card rank + card suit return ""; } }