From the README:
When using the Coin factory class, a valid coin value should be used. Not doing so can create undesirable Coin objects.
>>> coin = Coin(23)
OnePence(23)
# Use a CoinCollection instead!
>>> CoinCollection.from_value(23)
CoinCollection(TwentyPence(1), TwoPence(1), OnePence(1))
Re-thinking this I think it should be invalid to enter a state where an undesirable coin is about to be created (OnePence(23)).
I feel the correct way to handle this is to either raise an InvalidCoin exception. If a Coin has an .amount greater than 1, it's invalid.
From the README:
Re-thinking this I think it should be invalid to enter a state where an undesirable coin is about to be created (
OnePence(23)).I feel the correct way to handle this is to either raise an
InvalidCoinexception. If aCoinhas an.amountgreater than 1, it's invalid.