Code for my TDD workshop at the PHP UK Conference 2022
Together we will implement a Stack (Last In, Last Out) to the Collection Interface.
Individually or in pairs implement a Queue (First In, First Out) to the Collection Interface
Individually or in pairs implement a score function in the Bowling Game Class. The function
score()
will take a string representation of a single game of Bowling
e.g.
44 34 9/ X 13 -1 8- 53 -9 X4/
The function will return the score for the game.
The game consists of 10 frames. In each frame the player has two rolls to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares.
A spare is when the player knocks down all 10 pins in two rolls. The bonus for that frame is the number of pins knocked down by the next roll.
A strike is when the player knocks down all 10 pins on his first roll. The frame is then completed with a single roll. The bonus for that frame is the value of the next two rolls.
In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in tenth frame.
This Bowling Game Calculator may be useful to experiment with how the scoring works
During this Lab session I want you to implement the CardManager function sendCelebration(Person $person). When the function is fully implemented it should:
-
take a Person object.
-
Use the person object to retrieve an Event from the EventRetriever
-
the template that is used should be decided on by decided using event
- Type: Birthday
- Years: 1 - TEMPLATE_BABY
- Years: 2 to 4: TEMPLATE_TODDLER
- Years: 5 to 12: TEMPLATE_CHILD
- Years: 13 to 17: TEMPLATE_TEENAGER
- Years: 18+: TEMPLATE_ADULT
- Type Anniversary
- Years: 1 - TEMPLATE_PAPER
- Years: 25 - TEMPLATE_SILVER
- Years: 40 TEMPLATE_RUBY
- Years: 50 - TEMPLATE_GOLD
- Years: 60 - TEMPLATE_DIAMOND
- Years: Any Other - TEMPLATE_ANNIVERSARY
- If the EventRetriever throws a NoEventFoundException then nothing should be sent
- Type: Birthday
Together we will explore how Mutation Testing can give us confidence in our tests covering all eventualities of our code