public Hand(int n) { r = new Random(); ArrayList<Integer> used = new ArrayList<Integer>(); hand = new Card[n]; for (int i = 0; i < n; i++) { Card c = new Card(); while (used.indexOf(c.getID()) > -1) { c = new Card(); } used.add(c.getID()); hand[i] = c; } }
public void draw(int n) { Card[] temp = new Card[hand.length + n]; int i; for (i = 0; i < hand.length; i++) { temp[i] = hand[i]; } for (; i < hand.length + n; i++) { boolean found = true; Card c = new Card(); ; while (found) { c = new Card(); found = false; for (int k = 0; k < i; k++) { if (temp[k].getID() == c.getID()) { found = true; break; } } } temp[i] = c; } hand = temp; }
private boolean find(Card c) { return find(c.getID()); }