Skip to content

Commit d527d26

Browse files
committed
Example sent by Juqkai in Issue#1
1 parent fc821ca commit d527d26

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

fprg/guessANumber.fprg

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0"?>
2+
<flowgorithm fileversion="2.11">
3+
<attributes>
4+
<attribute name="name" value=""/>
5+
<attribute name="authors" value="Nicholas Bennett"/>
6+
<attribute name="about" value=""/>
7+
<attribute name="saved" value="2019-01-23 09:30:34 PM"/>
8+
<attribute name="created" value="TmljaG9sYXMgQmVubmV0dDtOQi1JTlNQSVJPTi0xNTsyMDE5LTAxLTIzOzExOjQyOjIwIEFNOzM3ODg="/>
9+
<attribute name="edited" value="TmljaG9sYXMgQmVubmV0dDtOQi1JTlNQSVJPTi0xNTsyMDE5LTAxLTIzOzA5OjMwOjM0IFBNOzc7MzkyNg=="/>
10+
</attributes>
11+
<function name="Main" type="None" variable="">
12+
<parameters/>
13+
<body>
14+
<while expression="playOneRound()"/>
15+
<output expression="&quot;Thanks for playing!&quot;" newline="True"/>
16+
</body>
17+
</function>
18+
<function name="inputAndCheck" type="Boolean" variable="playing">
19+
<parameters>
20+
<parameter name="secret" type="Integer" array="False"/>
21+
</parameters>
22+
<body>
23+
<declare name="playing" type="Boolean" array="False" size=""/>
24+
<assign variable="playing" expression="false"/>
25+
<output expression="&quot;What is your guess (1-100, 0 to give up)?&quot;" newline="True"/>
26+
<declare name="guess" type="Integer" array="False" size=""/>
27+
<input variable="guess"/>
28+
<if expression="guess == 0">
29+
<then>
30+
<output expression="&quot;You gave up!&quot;" newline="True"/>
31+
</then>
32+
<else>
33+
<if expression="guess == secret">
34+
<then>
35+
<output expression="&quot;Correct!&quot;" newline="True"/>
36+
</then>
37+
<else>
38+
<if expression="guess &lt; secret">
39+
<then>
40+
<output expression="&quot;Your guess of &quot; &amp; guess &amp; &quot; is too low.&quot;" newline="True"/>
41+
</then>
42+
<else>
43+
<output expression="&quot;Your guess of &quot; &amp; guess &amp; &quot; is too high.&quot;" newline="True"/>
44+
</else>
45+
</if>
46+
<assign variable="playing" expression="true"/>
47+
</else>
48+
</if>
49+
</else>
50+
</if>
51+
</body>
52+
</function>
53+
<function name="playOneRound" type="Boolean" variable="playAgain">
54+
<parameters/>
55+
<body>
56+
<declare name="secret" type="Integer" array="False" size=""/>
57+
<assign variable="secret" expression="1 + Random(100)"/>
58+
<while expression="inputAndCheck(secret)"/>
59+
<output expression="&quot;The secret number was &quot; &amp; secret &amp; &quot;.&quot;" newline="True"/>
60+
<output expression="&quot;Play again (y/n)?&quot;" newline="True"/>
61+
<declare name="userResponse" type="String" array="False" size=""/>
62+
<input variable="userResponse"/>
63+
<declare name="playAgain" type="Boolean" array="False" size=""/>
64+
<assign variable="playAgain" expression="Len(userResponse) &gt; 0&#13;&#10; &amp;&amp; (Char(userResponse, 0) == &quot;y&quot; || Char(userResponse, 0) == &quot;Y&quot;)"/>
65+
</body>
66+
</function>
67+
</flowgorithm>

0 commit comments

Comments
 (0)