IMPORTANT;use JGRASP for editing this java I have a file to start with and it should be done Monday.;Objectives - At the conclusion of this assignment students will have demonstrated that they can;Validate input data from a keyboard.;Use loops to repeat actions in a program;Use a Random number generator.;Organize operations into individual methods.;Properly format output to specification.;Do everything necessary to create, debug, and run a java program.;Use comments to delineate each section of the program.;Adhere to a Java Style Guide.;READ AND FOLLOW DIRECTIONS!!!!!;Background;The game of Ig has many variants. In this variant, a single die is used to play a game between the human and the computer. The goal is to be the first to reach 100 points by rolling the die. A player may choose to roll the die any number of times. Each time the die is rolled the value of the die face is added to the player's turn score. If a player relinquishes the die to their oponent, all turn points are added to the person's bank. As soon as the points in the person's turn and their bank reach 100 points, that player wins. The catch in all of this is that if a 1 is rolled, the player loses all of their turn points and play automatically passes to the other player. So the idea is to not be too "iggy" and "hog" the die, but to relinquish control when there are "enough" points in the turn to bank.;In this assignment, you will use a Random object as the "die" which will produce random numbers in the range of 1-6 to represent the die faces. Each player will use this same die.;Player 1 will be a human player and will always go first. Player 2 will be the computer and will always go second. The goal of the human player is to beat the computer player.;Requirements;PART A-There is no part A for this PA.;PART B - Submitted to WebCAT.;You will write a Java program consisting of IgDriver and Ig.java, that must;Display a welcome message, "Let's Play Ig;Display a blank line;Prompt for the name of the human player.;Prompt for the name for the computer player.;Display a blank line.;Display the human player name with the line "%s's turn" where the substitution is the name of the player.;Display a blank line.;Display the prompt, "Roll(Y/N)? ". There is one space after the?.;If the player answers any variant of Y ("Y" or "y") "roll" the die and display the result. The result should be in the form of:(%s Roll: %d Turn: %d Score: %d\n", name, roll, turn, score), where roll is the value for that die roll, turn is the total points for this turn, and score is the total score for this player for all turns. This result should end with the new line character.;If the player answers the roll prompt with anything other than a variant of Y, turn passes to the computer player.;For the computer player, "throw" the dice and display the result of the roll in the same format as the human player. Since the computer cannot "choose" whether or not to continue, we will use the algorithm that if the computer accrues 12 or more points, their turn is over. Play will return ot the human player at that point.;Play ends when either player reaches 50 points. (There should be no turns after the human or computer player reaches 50).;Display a blank line and then the message "%s wins!" where the substitution is the name of the winning player.;See the sample dialog found here: GameDialog.txt;Special requirements: A roll of 1 is poison. If the die roll is a 1, then the player who rolled that die will lose all of their turn points. If a player chooses to end their turn (the computer at 12 or more points, the human by choosing n), the turn points go into their total score bank and cannot be lost. For example, if a player took a turn and accrued 12 points, then relinquished their turn to the computer, those 12 points become part of the permanent score. If the player takes another turn and accrues 15 points and then throws a 1, they lose the 15, but they still have the 12 from the prior turn.;Part B Structure;PA4.java is being given to you. It will bring a seed value in as a command line argument. See RandomLesson in the material for this unit and the demo in class. It will create a Random generator and pass that generator to IgGame's playGame method.;A IgGame starter is being given to you. IgGame.java has some "global variables" or in object terms, these are known as attributes. Since they are defined inside the class but outside of any method, their scope is to be visible in any method. So for example, when you want to add the turn points to the player's score, you will use the humanScore variable. These attributes are all initialized to 0 or null for reference types.;IgGame will have the following required methods;public int playGame(Random randGen) - controls the action of the game. It takes in a Random object and returns nothing. It should instantiate the Scanner object so that one Scanner can be used throughout the game.;public void printScore(String name, int roll, int turn, int score) - prints the current state of the game after each player throws the die. The name is the name of the player to report, the roll is the value of the current roll, the turn is the score for that turn including this current roll and the score is the score as of this roll (turn + previous score). Note that you should not update the score in playerTurn since they may lose those points.;public int playerTurn() - controls one complete turn for the human player. It should return the turn score for the player.;public int computerTurn() - controls one complete turn for the computer player. It should return the turn score for the computer.;You may add additional methods to IgGame.java.
Paper#64299 | Written in 18-Jul-2015Price : $32