Skip to content

Don't allow invalid coins #4

@alxwrd

Description

@alxwrd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions