{"id":1377,"date":"2015-06-01T00:01:47","date_gmt":"2015-06-01T07:01:47","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=1377"},"modified":"2015-06-08T06:51:49","modified_gmt":"2015-06-08T13:51:49","slug":"lets-go-bowling-an-entire-game","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=1377","title":{"rendered":"Let&#8217;s Go Bowling &#8211; An Entire Game!"},"content":{"rendered":"<p>In last month&#8217;s <a href=\"http:\/\/c-for-dummies.com\/blog\/?p=1336\">Exercise<\/a>, the assignment was to craft a single frame in a game of bowling. This time, you need to stitch together 10 frames to simulate bowling an entire game.<br \/>\n<!--more--><br \/>\nAs a review, a single frame in bowling involves several parts: Up to two balls can be rolled to knock down 10 pins. When you knock down all ten the first time, you get a <em>strike<\/em>, represented by the letter <strong>X<\/strong>. If you fail to knock down all ten, you roll a second ball. Knock down all ten pins with that ball and you get a <em>spare<\/em>, represented by the <strong>\/<\/strong> symbol.<\/p>\n<p>Last month you had to score only a single frame. In a true game, the scoring works differently:<\/p>\n<ul>\n<li> A strike scores 10 points plus the total of the next two balls rolled.<\/li>\n<li> A spare scores 10 points plus the total of the next ball rolled.<\/li>\n<li> For neither a spare nor strike, the frame&#8217;s score is the sum of the two balls rolled.<\/li>\n<\/ul>\n<p>Due to the way a spare and strike are scored, the 10th (final) frame provides the opportunity for up to two more balls to be rolled: If you bowl a strike in frame 10, you get two extra balls. If you bowl a spare, you get another ball. That condition makes the tenth frame special, which is something to consider when scoring an entire game.<\/p>\n<p>Your assignment is to simulate a full game of bowling, all 10 frames.<\/p>\n<p>The code should output the game similar to what&#8217;s shown in Figure 1, although your code doesn&#8217;t have to match that output exactly.<\/p>\n<div id=\"attachment_1387\" style=\"width: 583px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1387\" src=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2015\/06\/bowling_exercise-fig1.png\" alt=\"Figure 1. Bowling simulation, 10 frames.\" width=\"573\" height=\"72\" class=\"size-full wp-image-1387\" srcset=\"https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2015\/06\/bowling_exercise-fig1.png 573w, https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2015\/06\/bowling_exercise-fig1-300x38.png 300w, https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2015\/06\/bowling_exercise-fig1-500x63.png 500w\" sizes=\"auto, (max-width: 573px) 100vw, 573px\" \/><p id=\"caption-attachment-1387\" class=\"wp-caption-text\">Figure 1. Bowling simulation, 10 frames.<\/p><\/div>\n<p>This is a tricky exercise, so give yourself plenty of time for trials and errors. <a href=\"http:\/\/c-for-dummies.com\/blog\/?p=1400\">Click here<\/a> to view my solution. Please attempt the Exercise on your own before looking to see what I&#8217;ve done.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Time to wrack up the scores for 10 frames of bowling action. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=1377\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1377","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1377"}],"version-history":[{"count":5,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1377\/revisions"}],"predecessor-version":[{"id":1422,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1377\/revisions\/1422"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}