0% found this document useful (0 votes)
20 views6 pages

Graded Learning Activity 02

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

Graded Learning Activity 02

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Graded Learning Activity 02: Dice Pool

Dice are used in many tabletop games to implement various game


mechanics. Dice come in a variety of shapes and sizes, with four, six,
eight, ten, twelve, or twenty sides. Many games need you to assemble a
collection of different-sized dice and roll them together. Create a program
to imitate dice for a tabletop game.

Create a class for a single dice. The constructor should accept an integer that
indicates how many sides the die has. The class should include a function that
simulates rolling the die and returns a random number from the valid range.

Create another class that represents a pool of dice. This class should include
functions for adding or removing a die from the pool. The class should also include a
function that rolls all of the dice in the pool and returns the total that was rolled.

//All commands
add 6
add 4
roll 4
roll 6
add 16
roll 16
roll 16
roll 16
rollall
add 8
add 10
remove 4
rollall

Classification:
General
remove 16
remove 6
remove 12
add 2
rollall
Exit

Sample input/output:

Enter Command:
add 6
Adding Dice 6...
Enter Command:
add 4
Adding Dice 4...
Enter Command:
roll 4
Dice 4, Roll Result: 2
Enter Command:
roll 6
Dice 6, Roll Result: 6
Enter Command:
add 16

Classification:
General
Adding Dice 16...
Enter Command:
roll 16
Dice 16, Roll Result: 11
Enter Command:
roll 16
Dice 16, Roll Result: 1
Enter Command:
roll 16
Dice 16, Roll Result: 6
Enter Command:
rollall
Rolling all Dice:
Dice 4: Roll Result: 3
Dice 6: Roll Result: 1
Dice 16: Roll Result: 16
Summation of all roll(s): 20.
Enter Command:
add 8
Adding Dice 8...
Enter Command:
add 10
Adding Dice 10...
Enter Command:

Classification:
General
remove 4
Removing Dice 4...
Remove Successful: True
Enter Command:
rollall
Rolling all Dice:
Dice 6: Roll Result: 6
Dice 8: Roll Result: 7
Dice 10: Roll Result: 5
Dice 16: Roll Result: 15
Summation of all roll(s): 33.
Enter Command:
remove 16
Removing Dice 16...
Remove Successful: True
Enter Command:
remove 6
Removing Dice 6...
Remove Successful: True
Enter Command:
remove 12
Removing Dice 12...
Remove Successful: False
Enter Command:

Classification:
General
add 2
Adding Dice 2...
Enter Command:
rollall
Rolling all Dice:
Dice 2: Roll Result: 1
Dice 8: Roll Result: 1
Dice 10: Roll Result: 9
Summation of all roll(s): 11.
Enter Command:
Exit

Grading Rubrics (Total 10 points):


1 The program with relevant code compiles and shows no compile-time 2
. error messages.
2 The program is readable. Naming for classes/methods/variables is/are 2
. appropriate. Functionality is decomposed into classes/methods. Line
indentation is applied and has followed good programming practices.
3 Important program codes (classes/methods/blocks/logic) have comments 2
. for understanding the implementation concepts/description. Simple
implementation overall. Program code is logical and does not contain
unnecessary/ redundant codes.
4 The program outputs correct values /strings/information in proper order 2
. (ascending, when appropriate).
5 The program does not show run time errors after executing single/multiple 1
. times.
6 The output is in exact formatting (sentences/lines/spacing) given in the 1
. sample example.

Classification:
General
Classification:
General

You might also like