Package model
Class Player
java.lang.Object
model.Person
model.Player
Represents a player in a blackjack game. A player has a name and a hand of cards. They can take actions such as hitting, standing, and doubling down. They can also make bets and receive payouts.
This class extends the Person class, which contains shared methods
and properties between players and dealers.
- Author:
- Michael Neuper michael@michaelneuper.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets the player's current balance from a file.voidsetBalance(double balance) Sets the player's balance and stores it in a file.Methods inherited from class model.Person
getHand, getName, hasBlackjack, hit, printFilePath, printHand, setHand, setName
-
Constructor Details
-
Player
public Player()Constructs a newPlayerobject with a default name of "Player".
-
-
Method Details
-
getBalance
public double getBalance()Gets the player's current balance from a file. If aFileNotFoundExceptionis thrown during the file reading process, it is caught and printed to the standard error stream.- Returns:
- balance the player's current balance
-
setBalance
public void setBalance(double balance) Sets the player's balance and stores it in a file. If aFileNotFoundExceptionis thrown during the file reading process, it is caught and printed to the standard error stream.- Parameters:
balance- the new balance to set
-