
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)
![brece Programming Project 4
O OOPig (0-0 Pig)
+
A Not Secure | nifty.stanford.edu/2010/neller-pig/doc/index.html
PREV CLASS NEXT CLASS
SUMMARY: NESTED FIELD CONSTR I METHOD
FRAMES NO FRAMES
DETAIL: FIELD | CONSTR I METHOD
All Classes
Die
HoldAt20PigPlayer
OOPig
PigGame
PigPlayer
UserPigPlayer
Class OOPig
java.lang.Object
-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
o 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)
Package Class Tree Deprecated Index Help
PREV CLASS NEXT CLASS
SUMMARY: NESTED | FIELD CONSTR | METHOD
FRAMES NO FRAMES
DETAIL: FIELD| CONSTR I METHOD](https://content.bartleby.com/qna-images/question/75449ef3-fcc1-42e7-9af4-d9c30b92c4e1/7d0a13cd-358d-4a53-84e7-ae8dea773ca6/yau2jzd_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 7 images

- JAVADesign a GUI that has four buttons. When the user press each of the buttons, it displays a message such that "You clicked button1.", "You clicked button2.", "You clicked button3.", or "You clicked button4".arrow_forwardIn javascript: Page #1: Greets User 1 (The Word Chooser) and asks for their Name, a word, and the number of wrong guesses they would like to give User 2(The Guesser).User 1 then clicks the "Go" button, which leads to page 2. Page #2: Greets User 2 by telling them the word choosers name and how many guesses they have been given for the word, they initially see a "-" for each unguessed letter, and a counter with remaining bad guesses. They must also be shown previously guessed letters. There is a place for them to enter their name and to guess letters. After all guesses are done, win or lose, the page goes to: Page #3: Congratulates the user, or informs them of their failure to guess the word. This page must show: User 1 Name User 2 Name Word they were trying to guessarrow_forwardPlease Solve this in Javaarrow_forward
- Java prgm basedarrow_forwardPython Code: ###########################################class MovieNode: def __init__(self, title, year, director, genre): self.title = title self.year = year self.director = director self.genre = genre self.next = None self.prev = None def __str__(self): return f"Title: {self.title:<25} Year: {self.year:<6} Director: {self.director:<20} Genre: {self.genre:<10}" def __lt__(self, other): if self.title < other.title: return True else: return False ###########################################class MovieList: def __init__(self): self.head = None self.tail = None def display(self): curr = self.head while curr: print(curr) curr = curr.next # Append new_movie at end of MovieList def append_movie(self, new_movie): # simply adding book to the end of the ddl if self.head == None: self.head = new_movie…arrow_forwardGuitarString.javaCreate a data type to model a vibrating guitar string. Write a class named GuitarString that implements the following API:arrow_forward
- ln OOP perspective, it is nothing but an instance of a class that contains real values instead of variables.A.MethodB.VariableC.ClassD.Objectarrow_forwardClass HoldAt20PigPlayer java.lang.Object HoldAt20PigPlayer All Implemented Interfaces:PigPlayerpublic class HoldAt20PigPlayerextends java.lang.Objectimplements PigPlayer HoldAt20PigPlayer - a Pig player that rolls as long as the turn total is less than 20 and the player's score plus the turn total is less than the goal score PigGame.GOAL_SCORE. Constructor Summary HoldAt20PigPlayer() 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 HoldAt20PigPlayer public HoldAt20PigPlayer() 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. The…arrow_forwardjava Jframe 6. Cell Phone PackagesCell Solutions, a cell phone provider, sells the following packages:300 minutes per month: $45.00 per month800 minutes per month: $65.00 per month1500 minutes per month: $99.00 per monthThe provider sells the following phones (a 6 percent sales tax applies to the sale of a phone):Model 100: $29.95Model 110: $49.95Model 200: $99.95Customers may also select the following options:Voice mail: $5.00 per monthText messaging: $10.00 per monthWrite an application that displays a menu system. The menu system should allow the userto select one package, one phone, and any of the options desired. As the user selects itemsfrom the menu, the application should show the prices of the items selected.arrow_forward
- Python GUI tkinter: Using tkinter create a GUI that displays the word cat. The user clicks on the word and sees its synonyms as replacements. When the user selects a desired synonym the synonym replaces the original word. For example: cat The user clicks on that word and has these options listed in a listbox: animal friend companion The user clicks on animal so the GUI now says: animalarrow_forwardUsing a gui in java please create a tic tac toe game. Player can verse player or computer (buttons) Please create one the program using JFrame implements action listener More requirements belowarrow_forwardInstructions FineForOverdueBook.. + 1 using System; 2 using static System.Console; 3 using System.Globalization; 4 public class FineForOverdueBooks Create an application for a library and name it FineForOverdueBooks. 5 { The Main() method asks public static void Main() the user to input the 7 { number of books 8 // Write your main here. checked out and the } number of days they are 10 books, int days) 11 12 public static void DisplayFine(int overdue. Pass those { values to a method // Write your DisplayFine method named DisplayFine that here. displays the library fine, 13 14 } 15 } which is 10 cents per book per day for the first seven days a book is overdue, then 20 cents per book per day for each additional day. The library fine should be displayed in the following format: The fine for 2 book(s) f The numbers will vary based on the input. In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCulture Info method. In order to do this, include the…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





