Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with the following program with Java: public class Dice { //Variable to name side of dice and value private String DiceValue; private String

Need help with the following program with Java:

public class Dice {

//Variable to name side of dice and value

private String DiceValue;

private String DiceSide;

//default constructor:

public Dice() {

DiceValue="1";

DiceSide="side 1";

}//end constructor

//non default constructor

public Dice(String value, String side) {

DiceValue=value;

DiceSide=side;

}//end non default contructor

//getter method, accessor method

public String getDiceValue() {

return DiceValue;

}

public String getDiceSide() {

return DiceSide;

}//end get method

//Setter Method

public void setDiceValue(String newDiceValue) {

DiceValue=newDiceValue;

}

public void setDiceSide(String newDiceSide) {

DiceSide=newDiceSide;

}

public String toString() {

return DiceValue + " " + DiceSide;

}

}//end class

With the following code I need to write a Dice game between 2 players that will return the higher value of dice. It needs to use Setters and Getters please. I just dont know where to continue after seeing this code written.

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

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions