Kafe Hezam10,990 Points
I don't understand what does die_class() in the for loop do and why is it usefull?
I just don't understand what die_class() do and what function is it calling?
Steven Parker182,603 Points
The "die_class" was provided as an argument to the "Hand", and defines what kind of objects (die) will be rolled. The argument passed in will be the name of the class that defines those objects.
Each time "die_class()" is called, an object of that class is created so that it can be added to the "Hand". So, for example, if a hand is created by calling *
hands.Hand(size=5, die_class=dice.D6)" then you will get a set of 5 6-sided dice (which is typical for a Yahtzee game). Each call t "
die_class()" in that case will actually be creating a "D6" object.
Chul Kim2,341 Points
Just wondering is die_class just a random name that holds the actual class?
And the () is always used to call a certain function or class?