Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.image text in transcribed

//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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

2 6 6 .

Answered: 1 week ago

Question

What is the promary function of Dynamic study modules

Answered: 1 week ago