Guest User

Untitled

a guest
Jul 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. package blackjack;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. /**
  6.  *
  7.  * @author Bryan
  8.  */
  9. public class Player
  10. {
  11.     public static final int STAY = 0;
  12.    
  13.     private int wallet;
  14.     private String name;
  15.     private int bet;
  16.     private int score;
  17.     private ArrayList<Card> hand;
  18.    
  19.     public ArrayList<Card> deck = new ArrayList<Card>();
  20.    
  21.     public Player(int in1, String in2)
  22.     {
  23.         wallet = in1;
  24.         name = in2;
  25.        
  26.         score = 0;
  27.         bet = 0;
  28.        
  29.         hand = new ArrayList<Card>();
  30.         deck.makeDeck();
  31.     }
  32.    
  33.     /**
  34.      * Ends the players turn, he can no longer hit.
  35.      * @return constant STAY.
  36.      */
  37.     public int stay()
  38.     {
  39.         return STAY;
  40.     }
  41.    
  42.     /**
  43.      * Displays the player's score.
  44.      * @return the score of the player.
  45.      */
  46.     public int getScore()
  47.     {
  48.         return score;
  49.     }
  50.    
  51.     /**
  52.      * Displays the amount the player has bet.
  53.      * @return the current player's bet amount.
  54.      */
  55.     public int getBet()
  56.     {
  57.         return bet;
  58.     }
  59.    
  60.     /**
  61.      * Increases the amount of the player's total bet by the given amount.
  62.      * @param amount the amount the player wishes to increase his bet by.
  63.      */
  64.     public void raise(int amount)
  65.     {
  66.         bet += amount;
  67.     }
  68.    
  69.     /**
  70.      * Deals the player another card and increases his score accordingly.
  71.      */
  72.     public void hit()
  73.     {
  74.         hand += deck.get(0);
  75.         deck.remove(0);
  76.     }
  77.    
  78.     /**
  79.      * Totals up the score of all cards in the player's hand.
  80.      */
  81.     public void total()
  82.     {
  83.         int sum = 0;
  84.         for(int i = 0; !hand.isEmpty() && i < hand.getSize(); i++)
  85.             sum += hand.get(i).getCardValue();
  86.        
  87.         score += sum;
  88.     }
  89. }
Add Comment
Please, Sign In to add comment