Class OOPig java.lang.Object extended by OOPig public class OOPig extends java.lang.Object OOPig is the main console class for the Pig application. It is typically executed within a terminal (shell) window. Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 ("pig") is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player's turn, the player is faced with two decisions: roll - If the player rolls a 1: the player scores nothing and it becomes the opponent's turn. 2 - 6: the number is added to the player's turn total and the player's turn continues. hold - The turn total is added to the player's score and it becomes the opponent's turn. This is a text-based implementation of a game of Pig where the user plays against a "hold at 20 or goal" computer player that rolls until a 1 ("pig") is rolled, or the turn total is greater than or equal to 20, or the score plus the turn total is greater than or equal to 100. The first player is chosen randomly. Constructor Summary OOPig() Method Summary static void main(java.lang.String[] args) main - randomly selects whether the user goes first or not, prints which player the user will be, creates a new game with the user and a hold-at-20 player, and starts the game. Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Constructor Detail OOPig public OOPig() Method Detail main public static void main(java.lang.String[] args) main - randomly selects whether the user goes first or not, prints which player the user will be, creates a new game with the user and a hold-at-20 player, and starts the game. Output format: Before the game, randomly select which player the user will be, and print the line "You will be player #.", where # is the user's player number. Parameters: args - a String[] value (unused
Class OOPig
java.lang.Object
extended by OOPig
public class OOPig
extends java.lang.Object
OOPig is the main console class for the Pig application. It is typically executed within a terminal (shell) window. Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 ("pig") is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player's turn, the player is faced with two decisions:
roll - If the player rolls a
1: the player scores nothing and it becomes the opponent's turn.
2 - 6: the number is added to the player's turn total and the player's turn continues.
hold - The turn total is added to the player's score and it becomes the opponent's turn.
This is a text-based implementation of a game of Pig where the user plays against a "hold at 20 or goal" computer player that rolls until a 1 ("pig") is rolled, or the turn total is greater than or equal to 20, or the score plus the turn total is greater than or equal to 100. The first player is chosen randomly.
Constructor Summary
OOPig()
Method Summary
static void main(java.lang.String[] args)
main - randomly selects whether the user goes first or not, prints which player the user will be, creates a new game with the user and a hold-at-20 player, and starts the game.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
OOPig
public OOPig()
Method Detail
main
public static void main(java.lang.String[] args)
main - randomly selects whether the user goes first or not, prints which player the user will be, creates a new game with the user and a hold-at-20 player, and starts the game.
Output format:
Before the game, randomly select which player the user will be, and print the line "You will be player #.", where # is the user's player number.
Parameters:
args - a String[] value (unused)
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 7 images