Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the class Die to include another instance data (String), called color, to represent the color of a die. Add a getter/setter for this data.

Modify the class Die to include another instance data (String), called color, to represent the color of a die. Add a getter/setter for this data.

public class Die

{

private final intMAX = 6; // maximum face value

private intfaceValue; // current value showing on the die

//-----------------------------------------------------------------

// Constructor: Sets the initial face value.

//-----------------------------------------------------------------

public Die()

{

faceValue= 1;

}

public introll()

{

faceValue= (int)(Math.random() * MAX) + 1;

return faceValue;

}

// Face value mutator.

public void setFaceValue(intvalue)

{

faceValue= value;

}

// Face value accessor.

public intgetFaceValue()

{

return faceValue;

}

public String toString()

{

String result = Integer.toString(faceValue);

return result;

}

}

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

What is included in the biopsychosocial approach to developmentpg15

Answered: 1 week ago

Question

Prepare a constructive performance appraisal.

Answered: 1 week ago

Question

List the advantages of correct report formatting.

Answered: 1 week ago