/** * CS 231 — Project 1 * Hand * * Purpose: * Represents one Blackjack hand using the ArrayList class completed in Lab 1. */ public class Hand { // TODO: Declare a private ArrayList instance variable. // This ArrayList stores the cards currently in the hand. /** * Constructs an empty Hand. */ public Hand() { // TODO: Create the ArrayList that will store this hand's cards. } /** * Removes all cards currently in the hand. */ public void reset() { // TODO: Reset the hand so that it contains no cards. // // Hint: Think about whether you need to remove cards one at a time, // or whether there is a simpler way to give the Hand a new empty list. } /** * Adds the specified card to the hand. * * @param card the card to add */ public void add(Card card) { // TODO: Add card to the ArrayList. } /** * Returns the number of cards currently in the hand. * * @return the number of cards in the hand */ public int size() { // TODO: Return the number of cards stored in the ArrayList. return 0; } /** * Returns the card at the specified index. * * @param index the index of the card * @return the card at index */ public Card getCard(int index) { // TODO: Return the requested Card. return null; } /** * Returns the total value of all cards in the hand. * * @return the summed value of the cards */ public int getTotalValue() { // TODO: // 1. Start a running total at 0. // 2. Visit each Card currently in the hand. // 3. Add that Card's value to the running total. // 4. Return the total. return 0; } /** * Returns a String representation of the hand and its total value. * * Example: * [2, 3, 4] : 9 * * @return a String representation of the hand */ public String toString() { // TODO: Produce the required format. // // Hint: Your ArrayList and Card classes already know how to create // useful String representations. Use that work rather than rebuilding it. return ""; } }