Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package blackjack;
- import java.util.ArrayList;
- /**
- *
- * @author Bryan
- */
- public class Player
- {
- public static final int STAY = 0;
- private int wallet;
- private String name;
- private int bet;
- private int score;
- private ArrayList<Card> hand;
- public ArrayList<Card> deck = new ArrayList<Card>();
- public Player(int in1, String in2)
- {
- wallet = in1;
- name = in2;
- score = 0;
- bet = 0;
- hand = new ArrayList<Card>();
- deck.makeDeck();
- }
- /**
- * Ends the players turn, he can no longer hit.
- * @return constant STAY.
- */
- public int stay()
- {
- return STAY;
- }
- /**
- * Displays the player's score.
- * @return the score of the player.
- */
- public int getScore()
- {
- return score;
- }
- /**
- * Displays the amount the player has bet.
- * @return the current player's bet amount.
- */
- public int getBet()
- {
- return bet;
- }
- /**
- * Increases the amount of the player's total bet by the given amount.
- * @param amount the amount the player wishes to increase his bet by.
- */
- public void raise(int amount)
- {
- bet += amount;
- }
- /**
- * Deals the player another card and increases his score accordingly.
- */
- public void hit()
- {
- hand += deck.get(0);
- deck.remove(0);
- }
- /**
- * Totals up the score of all cards in the player's hand.
- */
- public void total()
- {
- int sum = 0;
- for(int i = 0; !hand.isEmpty() && i < hand.getSize(); i++)
- sum += hand.get(i).getCardValue();
- score += sum;
- }
- }
Add Comment
Please, Sign In to add comment