Question: i need a java code for this question .. This is what i have so far please help. We are suppose to use objects in

i need a java code for this question .. This is what i have so far please help. We are suppose to use objects in this assignment. i need a java code for this question .. This is

//import scanner class import java.util.Scanner; //import random class import java.util.Random; //import Array class import java.util.Arrays;

//public class Yahtzee { //main method public static void main(String[] args){ //initialize int variable for the dice int dice = 5; //set it equal to 5 (there are 5 dice) //create an instance of the Random class (random numbers are from 1-6) Random randomNum = new Random(); //create an instance of the Scanner class Scanner sc = new Scanner(System.in); //create an array holding 5 values int [] new_Array=new int[dice]; //--First Roll-- //for loop for (int i=0; i

}

Exercise 2 of 2: Create a program that lets the player play a simplified game of Yahtzee. The game starts with the user throwing five 6-sided dice. The user can choose which dice to keep and which dice to re-roll. The user can re-roll a maximum of 2 times. After two times, the user has 5 dice with a certain value. The player then has to choose where they want their final combination of dice values applied. The following list is a simplified Yahtzee card, which we will use for this game: Ones, Twos, Threes, Fours, Fives, Sixes, 3 of a kind, 4 of a kind, Full House, Straight, Yahtzee For a Full House, the player needs 3 of a kind AND 2 of a kind. For a Straight, the player needs to have all 5 dice in consecutive order, i.e. either 1 ,2, 3, 4, 5, or 2, 3, 4, 5, 6. Yahtzee means 5 of a kind. If the player applies his dice score to something inapplicable, e.g. the player only has 2 of a kind, but applies it to 3 of a kind, or the player has no Ones, but applies his dice result to the Ones category, he scores zero in this category. Implementing the Bonus, Small Straight, and Chance (as usually available in most Yahtzee games) is not required for this homework exercise. Requirement: You wil need a random number generator for the dice roll. Make use of objects, which means either create a Dice class for the 5 dice, or implement a class that represents the 5 dice together (the choice is up to you.) Also, as mentioned, the player can re-throw his dice up to two times. The player can chose which dice to re-throw and which to keep

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!