How would you implement a minimal game of bowling in Xcode using TDD? The only API’s you need to implement are “roll” (a ball) and “score” (to get the current score).
Sigiloso
Basically you’ll create a “Bowling” or “Player” class and into that you’ll add “roll” and “score” methods. To test this little app, you’ll need to write some tests that demonstrate predictable results given various inputs (e.g. “roll” takes an input parameter of the number of pins currently standing and outputs the score only from that particular roll/frame, so you can’t have greater than 10 pins knocked down). I wrote my app in Objective-C, but I think they’ll also accept Swift. The Player class also needs to keep track of frames (i.e. which can advance by either a strike or two rolls of the ball). Score can return the total score across all the frames, but the tests you’ll write will look for predictable results after the first couple rolls of the balls.