diff --git a/Personal/Cards/src/Hand.java b/Personal/Cards/src/Hand.java new file mode 100644 index 0000000..c7476ed --- /dev/null +++ b/Personal/Cards/src/Hand.java @@ -0,0 +1,61 @@ +import java.util.ArrayList; +import java.util.List; + +public class Hand { + private List listOfCards = new ArrayList(); + + public Hand() { + } + + @Override + public String toString() { + StringBuilder handofSuit = new StringBuilder(); + + handofSuit.append("["); + for (Card card : listOfCards) { + handofSuit.append(card.getFace() + ","); + } + if (handofSuit.length() != 1) + handofSuit.deleteCharAt(handofSuit.length() - 1); + handofSuit.append("]"); + + return handofSuit.toString(); + + } + + public Card sevensCheckCardExists(int userCardFace, String userCardSuit) { + for (Card card : listOfCards) { + if (card.getFace() == userCardFace && card.getSuit().equals(userCardSuit)) + return card; + } + return null; + } + + public Hand(List listOfCards) { + this.listOfCards = listOfCards; + } + + public void addCard(Card card) { + listOfCards.add(card); + } + + public void addCard(int index, Card card) { + listOfCards.add(index, card); + } + + public void removeCard(int index) { + listOfCards.remove(index); + } + + public void removeCard(Card card) { + listOfCards.remove(card); + } + + public List getListOfCards() { + return listOfCards; + } + + public void setListOfCards(List listOfCards) { + this.listOfCards = listOfCards; + } +}