Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that uses the Die class to play a simple dice game between the computer and the user. The program should create two

Write a program that uses the Die class to play a simple dice game between the computer and the user. The program should create two instances of the Die class (each a 6 side die). One Die object is the computers die and the other Die object is the users die.

The program should have a loop that iterates 10 times. Each time the loop iterates it should roll both dice. The die with the highest value wins. (in case of a tie there is no winner for that particular roll of the dice)

As the loop iterates the program should keep count of the number of times the computer wins, and the number of times that the user wins. After the loop performs all of its iterations, the program should display who was the grand winner the computer or the use. Use following UML diagram to design your class.

Class: Die

Data Members:

-computername: String

-username: String -sides : int - value : int

Method Members: +Die(sides : int)

+Die(computename:String,username:String) + getSide() :int + setSide(sides : int) : void + getValue() : int + setValue(value : int) : void +roll() : void

+getComputername(): String

+setComputername(value: String):void

+getUsername(): String

+setUsername(value:String): void

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_2

Step: 3

blur-text-image_3

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

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions

Question

Did the team members feel that their work mattered

Answered: 1 week ago

Question

3. What may be the goal of the team?

Answered: 1 week ago