Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Program :

Simulating Dice with Objects

Dice traditionally have six sides, representing the values 1 to 6. Some games, however, use specialized dice that have a different number of sides.

For example, the fantasy role-playing game Dungeons and Dragons® uses dice with four, six, eight, ten, twelve, and twenty sides.

Suppose you are writing a program that needs to roll simulated dice with various numbers of sides. A simple approach would be to write a Die class with a constructor that accepts the number of sides as an argument.

The class would also have appropriate methods for rolling the die and getting the die's value.

Write a program that defines a class die. There are 2 member variables of type int.

sides - an int variable that will hold the number of sides for the die.

(for this pgrm assume the die has either 6 or 12 sides).

value - an int variable that will hold the dies value once it has been rolled.

Constructor -The constructor should get the system time and use that number to seed the random number generator. The constructor accepts an arguments for the number of sides of the die and performs an initial roll().

Roll - The roll member function simulates the rolling of the die. The random number generator should be executed returning a random number within the range for this particular die.

getsides - member function returns the sides member variable.

getvalue - member function returns the value member variable.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93094763

Have any Question?


Related Questions in Computer Engineering

Recommend a mechanism that will record event data on the

Recommend a mechanism that will record event data on the folders for each department. What events should be logged and how often do these logs need to be reviewed? Recommend an implementation for antivirus software. Sugg ...

Once considered pure science fiction artificial

Once considered pure science fiction, artificial intelligence (AI) is being relied on more and more in today's world. Artificial intelligence deals with algorithms based on complex data sets. If you had to tell story rep ...

Question when a syscall is called which register must have

Question : When a syscall is called which register must have the syscall number? Which syscall is a must for every program? Why?

A balloon has 050 mol ar at 175 k 0997 atm and 0775 l if

A balloon has 0.50 mol Ar at 175 K, 0.997 atm and 0.775 L. If the moles are doubled and the temperature dropped to 115 K at constant pressure, what would the volume (in L) be?

The researchers stated that there were no significant

The researchers stated that there were no significant differences in the baseline characteristics of the intervention and control groups. Are these groups heterogeneous or homogeneous at the beginning of the study? Why i ...

Ethanol has a density of 78gml how many grams of ethanol

Ethanol has a density of .78g/mL. How many grams of ethanol are present in to deliver 13.2 mL?

A scavenger hunt question from the assigned

A scavenger hunt question from the assigned readings.) Consider the statement if ((a! = null)&&(a.x()))a.y(); What feature of the a && b makes it classify as a control structure? Rewrite this as 2 nested if statements. W ...

A stock is expected to pay a 400 dividend per share the

A stock is expected to pay a $4.00 dividend per share. The growth rate is expected to be 5%. If investors demand 10% on this stock, what is the expected price of the stock 10 years from now?

Suppose there are three decks of cards on the table a

Suppose there are three decks of cards on the table, a number is written on each card. And each deck is sorted in decreasing order (The maximum value is on the deck in top). The goal is to find the minimum value between ...

Question recently it has become obvious that people are

Question: Recently it has become obvious that people are storing data where it does not belong and people are accessing files and directories that they should not have access to. Elizabeth Montgomery is in charge of the ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As