November 2017
Intermediate to advanced
670 pages
17h 35m
English
Now, it's time to provide the duck with its starting resources and a list of ponds to swim in and see whether our duck survives to live another day.
Let's assume our duck has five bugs in its belly, which is worth five strokes (we made our ponds and bugs very small to simplify our model):
func main() { var duck Duck capabilities := Capabilities{ StrokeBehavior: Foot{}, EatBehavior: Bill{}, strokes: 5, }
Our duck's first set of ponds will consist of two ponds. Each supplies only one bug. The first pond requires three strokes to reach the other side. The second pond requires two strokes:
ponds := []Pond{ {BugSupply: 1, StrokesRequired: 3}, {BugSupply: 1, StrokesRequired: 2},}duck.SwimAndEat(&capabilities, &capabilities.strokes, ...