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

  What is the limit squeeze theorem

What is the limit squeeze theorem? How can you use this theorem to solve limit problems?

  What is the temprature of the plate

We have used linear one-dimensional elements to approximate the temperature distribution inside a metal plate. A heating element is embedded within a plate.

  Will this be the if.else and looping

How will you use control flow in computer programming to solve problems.

  Outline sound practices for reducing input errors

Outline sound practices for reducing input errors. Briefly discuss each

  Improving the speed of e-mails

Insurance, a multi million-dollar life insurance firm, has asked you to help troubleshoot the network at its corporate headquarters.

  Examine the importance and purpose of of n-tier systems

Examine the importance and purpose of of n-tier systems

  What is the time complexity

What is the output when n = 2, n = 4, and n = 6? What is the time complexity T(n)? You may assume that the input n is divisible by 2.

  Write one program and display the results at the same time

Write one program and display the results at the same time. You must use the Debian version of the UNIX operating system.

  Distinguish between diffusion and confusion

Define a product cipher and list the two classes of product ciphers. Distinguish between diffusion and confusion.

  Define the system reliability

Suppose you were tasked with designing and implementing an ultra-reliable and ultra-available operating system. What techniques would you use?

  Write a research paper and paper presentation on encryption

Write a research paper and paper presentation On Encryption. What is the current cybersecurity-related situation involving the Encryption?

  How have the assumptions in the models changed

Recent predictions for population growth in the 21st century have changed quite a bit from predictions made. How have the assumptions in the models changed?

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