Part A Create a class called die (the singular of dice). The die class should have a single data member called value. The die constructor should initialize the die’s value to 1. Create a member function called roll() that gives the die a random value between 1 and 6. Create a member function called show() that displays value. In main, demonstrate the creation of a die object to validate it is working. Part B Revise main to count the number of occurrences of each die value. The best result is maximum number of any particular value. If you have the same number of two values, the higher value determines the best result. Sample Output: Roll: 23541 Best result: You have one 5 Roll: 12346 Best result: You have one 6 Roll: 41321 Best result: Two of a kind: 1 Roll: 44364 Best result: Three of a kind: 4 Roll: 65533 Best result: Two of a kind: 5 (Note: even though there are two three's, the two five's make up the better result.)
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
C++
Part A Create a class called die (the singular of dice). The die class should have a single data member called value. The die constructor should initialize the die’s value to 1. Create a member function called roll() that gives the die a random value between 1 and 6. Create a member function called show() that displays value. In main, demonstrate the creation of a die object to validate it is working.
Part B Revise main to count the number of occurrences of each die value. The best result is maximum number of any particular value. If you have the same number of two values, the higher value determines the best result. Sample Output: Roll: 23541 Best result: You have one 5 Roll: 12346 Best result: You have one 6 Roll: 41321 Best result: Two of a kind: 1 Roll: 44364 Best result: Three of a kind: 4 Roll: 65533 Best result: Two of a kind: 5 (Note: even though there are two three's, the two five's make up the better result.)

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images









