<?xml version="1.0" encoding="UTF-8"?>
<linguagem>
    <topico>
		<nome>Dojo #29: Boliche</nome>
		<titulo>Boliche</titulo>
 		<descritor>apoie, apoie.org, Dojo, Dojo Rio, Coding Dojo, Kata, Tabela de Decisões, programa, simplificar, método, LDC, Jogo de Boliche</descritor>
		<lead>Exemplo de uso de &lt;a href=&quot;TabelaDecisoes.html&quot; target=&quot;_blank&quot;&gt;Tabela de Decisões&lt;/a&gt; para o &lt;a href=&quot;http://www.codingdojo.org/cgi-bin/wiki.pl?back=KataBowling&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Kata Boliche&lt;/span&gt;&lt;/a&gt; realizado em 19 de agosto de 2009 na &lt;a href=&quot;http://dojorio.wordpress.com/2009/08/28/coding-dojo-rio-29/#more-395&quot; target=&quot;_blank&quot;&gt;Reunião #29&lt;/a&gt; do &lt;a href=&quot;http://dojorio.wordpress.com/&quot; target=&quot;_blank&quot;&gt;Dojo Rio&lt;/a&gt;</lead>
		<origem>DojoBoliche.xml</origem>
		<fonte></fonte>
    </topico>
	<topico> 
       	<titulo>Problema</titulo>
		<desc>		  &lt;p&gt;Create a program, which, given a valid sequence of rolls	for one line of American Ten-Pin Bowling, produces the total score for	the game. Here are some things that the program will not do:&lt;/p&gt;		  &lt;ul&gt;			&lt;li&gt;We will not check for valid rolls.&lt;/li&gt;			&lt;li&gt;We will not check for correct number of rolls and	frames.&lt;/li&gt;			&lt;li&gt;We will not provide scores for intermediate frames.&lt;/li&gt;		  &lt;/ul&gt;		  &lt;p&gt;Depending on the application, this might or might not be	a valid way to define a complete story, but we do it here for purposes	of keeping the kata light. I think you'll see that improvements like	those above would go in readily if they were needed.&lt;/p&gt;		  &lt;p&gt;We can briefly summarize the scoring for this form of	bowling:&lt;/p&gt;		  &lt;ul&gt;			&lt;li&gt;Each game, or &quot;line&quot; of bowling, includes ten turns,	or &quot;frames&quot; for the bowler.&lt;/li&gt;			&lt;li&gt;In each frame, the bowler gets up to two tries to	knock down all the pins.&lt;/li&gt;			&lt;li&gt;If in two tries, he fails to knock them all down, his	score for that frame is the total number of pins knocked down in his	two tries.&lt;/li&gt;			&lt;li&gt;If in two tries he knocks them all down, this is	called a &quot;spare&quot; and his score for the frame is ten plus the number of	pins knocked down on his next throw (in his next turn).&lt;/li&gt;			&lt;li&gt;If on his first try in the frame he knocks down all	the pins, this is called a &quot;strike&quot;. His turn is over, and his score	for the frame is ten plus the simple total of the pins knocked down in	his next two rolls.&lt;/li&gt;			&lt;li&gt;If he gets a spare or strike in the last (tenth)	frame, the bowler gets to throw one or two more bonus balls,	respectively. These bonus throws are taken as part of the same turn. If	the bonus throws knock down all the pins, the process does not repeat:	the bonus throws are only used to calculate the score of the final	frame.&lt;/li&gt;			&lt;li&gt;The game score is the total of all frame scores.&lt;/li&gt;		  &lt;/ul&gt;		  &lt;p&gt;&lt;a href=&quot;http://www.topendsports.com/sport/tenpin/scoring.htm&quot;&gt;More info on the rules&lt;/a&gt;&lt;/p&gt;
		</desc>
    </topico>
	<topico> 
       	<titulo>Solução</titulo>
		<desc>total = 0&lt;br&gt;
			repete (rodada = 1 a 12)&lt;br&gt;
			&lt;div style=&quot;margin-left: 40px;&quot;&gt;total +=
			pontos(rodada) * qtd(rodada)&lt;/div&gt;</desc>
    </topico>
	<topico> 
       	<titulo>Detalhes</titulo>
			<desc>&lt;p&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;qtd&lt;/span&gt;
			= vetor indicando quantas vezes os pontos desta rodada serão contados,
			inicialmente
			= 1. Se houver:
			&lt;/p&gt;
			&lt;ul&gt;
			  &lt;li&gt;spare na rodada i soma 1 em qtd(i + 1);&lt;/li&gt;
			  &lt;li&gt;strike na rodada i soma 1 em qtd(i + 1) e em qtd(i +
			2)&lt;/li&gt;
			&lt;/ul&gt;
			&lt;span style=&quot;font-weight: bold;&quot;&gt;pontos&lt;/span&gt;
			= vetor com a quantidade de pontos de cada rodada</desc>
    </topico>
	<topico> 
       	<titulo>Definição usando &lt;a href=&quot;TabelaDecisoes.html&quot;
 target=&quot;_blank&quot;&gt;Tabela de Decisões&lt;/a&gt;</titulo>
		<desc>&lt;span style=&quot;font-family: Courier New,Courier,monospace;&quot;&gt;
Repetir para cada rodada:&lt;br&gt;
&lt;div style=&quot;margin-left: 40px;&quot;&gt;
Foi strike?&lt;br&gt;
| Foi spare? &lt;br&gt;
1 . * somar 10 e as duas rodada seguintes&lt;br&gt;
. 1 * somar 10 e a&amp;nbsp;rodada seguinte&lt;br&gt;
0 0 * somar pontuação da rodada&lt;/div&gt;
&lt;/span&gt;</desc>
    </topico>
	<topico> 
       	<titulo>Outra Solução</titulo>
		<desc>total = 0&lt;br&gt;
			repete (rodada = 1 a 10)&lt;br&gt;
			&lt;div style=&quot;margin-left: 40px;&quot;&gt;total +=
			pontos(rodada)&lt;br&gt;
			se tipo(rodada) &amp;lt&amp;gt; normal: total += pontos(rodada + 1)&lt;br&gt;
se tipo(rodada) = strike: total += pontos(rodada + 2)&lt;/div&gt;</desc>
    </topico>
	<topico> 
       	<titulo>Detalhes</titulo>
			<desc>&lt;span style=&quot;font-weight: bold;&quot;&gt;tipo&lt;/span&gt; =
			vetor indicando se:
			&lt;ul&gt;
			  &lt;li&gt;foi strike,&lt;/li&gt;
			  &lt;li&gt;spare ou&lt;/li&gt;
			  &lt;li&gt;não houve premiação&lt;/li&gt;
			&lt;/ul&gt;
			&lt;span style=&quot;font-weight: bold;&quot;&gt;pontos&lt;/span&gt;
			= vetor com a quantidade de pontos de cada rodada</desc>
    </topico>
</linguagem>