CardĬard has 3 methods Value() str, Face() str, Comparable() int and Valid() bool. It has 2 objects Card and Deck with helpful methods for a standard hearths card and a stack of cards. Package - Deckįirst I wrote the deck subpackage. They don't cover all scenarios, but they generally let me know when a new implementation affected something else. So this time around I wrote some simple tests.
Even after getting something right, if I wanted to change the implementation or some design decisions I spent a lot of time testing that other functionality still works as intended (and debugging why they don't). Last time I tried doing this I wasn't doing any tests and printing all the time (had a Print method on everything). While hearths subpackage part contains Board and Player objects specifically for a game of hearths and rules for interactions between them. With methods a card deck or a player's hand might need. Deck subpackage is just an independent package for managing a stack of cards. I separated the project into 2 parts - deck and hearths.