Write a program that defines a class die

Assignment Help Computer Engineering
Reference no: EM132107294

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.

Reference no: EM132107294

Questions Cloud

Stage of homogenization in effect on the material : What is role of the first and second stage of homogenization in their effect on the material?
Predominately using in this type of exercise : What sources of fuel is Jeremy predominately using in this type of exercise? How much fluid should Jeremy be consuming during a 3-hour run?
What is the overall speed of the system in blocks processed : The processing step takes 20 million clock cycles, and the clock rate is 400 MHz. What is the overall speed of the system in blocks processed per second?
Explain how fluid balance is regulated in the individual : Explain how the concept of obligatory water excretion helps to explain how fluid balance is regulated in the individual.
Write a program that defines a class die : Write a Die class with a constructor that accepts the number of sides as an argument.
Sugar substitutes-saccharine and aspartame : Explain why there have been health concerns about Saccharine (include any flaws in the early scientific studies) and explain why Saccharin
A program that allows a human to play against the computer : Class called Human_player. This should derive from the Player class. Class called Computer_player. This should derive from the Player class.
What other foods induce milk production : Would feeding moringa to cows also promote milk production? If yes or no, how or why? What other foods induce milk production?
Design and implement an application that plays the hi-lo : Consider using two do loops to solve this problem although there are many other correct ways if you prefer another solution.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Average access time of memory system

The access time to cache is 30 nanoseconds. The access time to memory is 120 nanoseconds. The data bus between cache and main memory is 128 bits wide. The hit rate on cache is 95%. 25% of the cache blocks are dirty.Specify the average access time o..

  Plan sequence using d flip flops

plan a circuit that would count in the following sequence using D Flip Flops

  Write a function to find the maximum and minimum element

Write a function to find the maximum and minimum element in a given list using methods.

  Determine the longest possible interval

Determine the longest possible interval [L, R] so that if GapEst is in this interval, then the 10 required conjunctions are computed in FindConj.

  Does the marie architecture owe more to aiken

Two pioneers of early computers and computer organization were Howard H. Aiken and John von Neumann - Is Aiken or is von Neumann associated with the so-called Princeton architecture?

  Obtains the choice and show action based on that choice

Implements a switch: show the user three choices, obtains the choice and display an action based on that choice. One of the actions will include an if..else. Also include a default for incorrect choices.

  How various cells can be in a computer''s main memory

Suppose a machine has 20GB of storage space available on a hard disk and receives data over a telephone connection at the rate of 14,400 bps. At this rate, how long will it take to fill the available storage space.

  Analyze the ongoing maintenance that will be required

Analyze the ongoing maintenance that will be required. Provide a workflow diagram in Visio or equivalent software to illustrate how the system will work.

  If the code needs improvement include a rewritten version

sourceforge javaforge and google code. pick any one of the 3 sites and find a program that uses at least one loop and

  What kind of tilings could be used to take advantage

Suppose we believe that one of two state dimensions is more likely to have. What kind of tilings could be used to take advantage of this prior knowledge?

  How the details in design brief helped in software selection

After doing analysis, you have decided to use Microsoft PowerPoint 2007. List and explain four critical points why didyou consider MSPowerPoint 2007 for this presentation. Also explain how the details in the design brief helped in software selectio..

  How do the sales volume in each store relate to revenues

How do the sales volume in each store relate to revenues? How does this relationship depend on the configuration?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd