Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Oriented Programming: Purpose: To create and use an array of object references. To create a class that involves using array logic. Step 1 Create

Java Oriented Programming:

image text in transcribed

image text in transcribed

image text in transcribed

Purpose: To create and use an array of object references. To create a class that involves using array logic. Step 1 Create a class called Die which represents an n-faced die that is used in game playing. a) The class has two fields, the number of sides the die has and the value of the side that is facing up (the face). b) Write a constructor which takes in an int as a parameter representing the number of sides the die has and then rolls the die to set the initial face value. This roll uses the Random class to determine the value of the face. Values on the die must be at least 1 and the upper limit is the number of faces. This means a standard six-faced die can have face values ranging from 1 to 6. use the Java random number generator to do this. (Random) c) write a compareTo() method to determine the ordering of two Die objects. This comparison is based solely on the value of the face field. d) write an equals() method to determine i two Die objects should be considered equal based on both the number of sides AND the current face value. e) Write a copy constructor. write a roll() method using the Random class which changes the value of the face field. g) Write a getFace() method. h) write a tostring() method that returns a text value of both the number of sides and the value of face. use the Blue debugger to test each of the methods of the Die class before going on step 2. Purpose: To create and use an array of object references. To create a class that involves using array logic. Step 1 Create a class called Die which represents an n-faced die that is used in game playing. a) The class has two fields, the number of sides the die has and the value of the side that is facing up (the face). b) Write a constructor which takes in an int as a parameter representing the number of sides the die has and then rolls the die to set the initial face value. This roll uses the Random class to determine the value of the face. Values on the die must be at least 1 and the upper limit is the number of faces. This means a standard six-faced die can have face values ranging from 1 to 6. use the Java random number generator to do this. (Random) c) write a compareTo() method to determine the ordering of two Die objects. This comparison is based solely on the value of the face field. d) write an equals() method to determine i two Die objects should be considered equal based on both the number of sides AND the current face value. e) Write a copy constructor. write a roll() method using the Random class which changes the value of the face field. g) Write a getFace() method. h) write a tostring() method that returns a text value of both the number of sides and the value of face. use the Blue debugger to test each of the methods of the Die class before going on step 2

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago