public class Hand { //double[] scores = new double[5]; private Card[] hand; private int numcards; public Hand() { hand = new Card[11]; numcards = 0; } public void addCard(Card c) { if(numcards < hand.length) { hand[numcards++] = c; } else { System.out.println("Cannot add card to hand"); } } /* * position = 0 to number of cards - 1 */ public void removeCard(int position) { position--; if(position < 0 || position > numcards - 1) { System.out.println("Cannot remove your card"); return; } for(int i = position; i < numcards-1; i++) { hand[i] = hand[i+1]; } numcards--; } public void display() { for(int i = 0; i < numcards; i++) { hand[i].display(); } } public static void main(String[] args) { Hand h = new Hand(); h.addCard(new Card(5, "Hearts")); h.addCard(new Card(12, "Diamonds")); h.addCard(new Card(1, "Spades")); h.removeCard(2); h.display(); } }