Class UserPigPlayer java.lang.Object UserPigPlayer All Implemented Interfaces:PigPlayerpublic class UserPigPlayerextends java.lang.Objectimplements PigPlayer UserPigPlayer - text interface to query user for roll/hold decisions Constructor Summary UserPigPlayer() Creates a new UserPigPlayer instance to allow user play via standard input Output format: Print an instruction line "Enter nothing to roll; enter anything to hold." Method Summary boolean isRolling(int myScore, int otherScore, int turnTotal) isRolling - return whether or not the player rolls, given the current game state. Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Constructor Detail UserPigPlayer public UserPigPlayer()Creates a new UserPigPlayer instance to allow user play via standard input Output format: Print an instruction line "Enter nothing to roll; enter anything to hold." Method Detail isRolling public boolean isRolling(int myScore, int otherScore, int turnTotal)isRolling - return whether or not the player rolls, given the current game state. Output format: Prompt the user with "Turn total: ", the turn total, a tab, and "Roll/Hold? ". Input format: An empty input (i.e., Enter) indicates that the user wishes to roll. Any entered line of non-zero length indicates that the user wishes to hold.
Class UserPigPlayer
java.lang.Object UserPigPlayer All Implemented Interfaces:PigPlayerpublic class UserPigPlayerextends java.lang.Objectimplements PigPlayer
UserPigPlayer - text interface to query user for roll/hold decisions
Constructor Summary |
---|
UserPigPlayer() Creates a new UserPigPlayer instance to allow user play via standard input Output format: Print an instruction line "Enter nothing to roll; enter anything to hold." |
Method Summary | |
---|---|
boolean | isRolling(int myScore, int otherScore, int turnTotal) isRolling - return whether or not the player rolls, given the current game state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
UserPigPlayer
public UserPigPlayer()Creates a new UserPigPlayer instance to allow user play via standard input
Output format:
- Print an instruction line "Enter nothing to roll; enter anything to hold."
Method Detail |
---|
isRolling
public boolean isRolling(int myScore, int otherScore, int turnTotal)isRolling - return whether or not the player rolls, given the current game state.
Output format:
- Prompt the user with "Turn total: ", the turn total, a tab, and "Roll/Hold? ".
Input format:
- An empty input (i.e., Enter) indicates that the user wishes to roll. Any entered line of non-zero length indicates that the user wishes to hold.
Specified by:isRolling in interface PigPlayerParameters:myScore - an int value - the player's scoreotherScore - an int value - the opponent's scoreturnTotal - an int value - the player's current turn totalReturns:a boolean value - whether or not the player will continue to roll
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images