For properties like "diceOutCome2", you are actually better off using a list with index numbers, like counter.diceOutCome[2]
. This allows you to easily iterate over all the list of diceOutcomes, or to refer to the outcome before the 5th dice outcome as counter.diceOutCome[n-1]
when n is 5.
Horn bets can be computed as methods on an object, either the counter object that you referenced before (counter.highHorn(5)
could evaluate the winning or losing of a high horn bet on counter.diceOutcome[5]
), or on the object used to represent the die roll outcome, a list of which is kept in diceOutCome, as in counter.diceOutcome[5].highHorn()
. Or HighHorn
could be an subclass of Bet
; an instance of HighHorn
is constructed using a DiceOutcome, and HighHorn
would implement a wins()
method, defined in abstract on Bet
, to be implemented in subclasses - evaluating it as HighHorn(counter.diceOutCome[5]).wins()
. Since the diceOutcomes are all attached to counter
, then this might be a logical item to pass around to related methods, or a logical item on which to define those methods.
In general, if you start thinking about defining variable names with trailing numeric digits, for instance that something1
, something2
, something3
are going to be of use in your program, you must immediately stop and replace with a list called somethings
, and access them using list indices like somethings[2]
.
(Note - For ease of communication, I am using 1-based indexing to correspond to the descriptions - in actuality, indexes to the items in a sequence are 0-based, hence the 5th item would really be referenced as sequence[4]
, the item before it is sequence[4-1], the 1st item being found at
sequence[0]`. The point is, this is the case where indexes make sense, not numeric suffixes on variable names.)