[Solved] SOLVED:A Game of Pig

30 $

File Name: SOLVED:A_Game_of_Pig.zip
File Size: 188.4 KB

SKU: [Solved] SOLVED:A Game of Pig Category: Tag:

Or Upload Your Assignment Here:


Learning Objectives After completing this project you should be able to: · use a Graphical User Interface (GUI) · write methods to meet specific requirements · write conditional statements with boolean expressions · write a looping construct · write programs that include the use of several classes. Game Rules The game requires two six-sided dice. Players take turns until someone wins by earning at least 100 points Players begin a turn by rolling both dice and tallying the points. The current player continues rolling and accumulating points until rolling a ‘1’ or choosing to ‘hold’. If the player rolls a 1 then all points from this round are lost. If the player rolls a pair of 1s then all player points are lost. Play rotates to the next player Your game will be between a person and the computer. The player always goes first. Step 1: Create a New BlueJ Project – Project3 Step 2: Class Definition: GVdie Rather than writing your own Die class, we are providing a completed class for you. Download the GVdie class and use the The following sample shows partial results of a game. Your messages can be more creative as long as they convey the necessary information. Note: totals turns is only displayed during automated games. later in the game… Step 5: Adapt for a GUI (15 pts) Now that you have the basic game working within it’s own class it is time to create a more interesting graphical user interface for the player to use. Add the following methods to the Pig class. · Add a boolean instance variable to indicate if it is currently the player’s turn. You will need to make several changes throughout the Pig class to set this variable to true when it is the player’s turn and false when it is the computer’s turn. All games start with the player. · public boolean isPlayerTurn ( ) – this one line method returns true if it is the player’s turn or false if it is the computer’s turn. Rather than writing your own GUI class, we are providing the complete class. Download the GVdie class and use the 5. If the “Run Tests” button is not visible, go to Bluej Preferences. Under the “Miscellaneous” tab check the “Show unit testing tools” 6. On the BlueJ window, click the “Run Tests” button. If your class passes all the test cases, the test results window will show a green horizontal bar and zero failures.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] SOLVED:A Game of Pig
30 $