© serviceprofessionalgmbh

Knobeln, Schnippeln or however you might call it. This Version produces a result based on multiple queries. The aim of programming is always to code it as simple as possible. Hence it is not the question whether it would be possible to work with boolean expressions - of course, one could. But what makes an expression complicated ? One AND? A tripple AND and 4 times OR? This is quite personell opinion. No boolean operators at all are very simple.


/* REXX
*/
obj.1="Stein"
obj.2="Schere"
obj.3="Papier"
obj.4="Brunnen"
obj.5="ENDE"
erg.1="unentschieden"
erg.2="ich habe gewonnen"
erg.3="Du hast gewonnen"
do forever
   say center("< Die kleine Knobelei >",79,"-");say;say
   do I = 1 to 5
      say center(I "=" left(OBJ.I,8),79)
   end
   say
   do until wordpos(s,"1 2 3 4 5") > 0
      say center("Triff Deine Auswahl",79)
      parse external s
   end
   if s = 5 then leave
   r=random(1,4)
   say;say "Du hast" obj.s", ich habe" obj.r
   select
      when r=s then e=1
      when r=1 then if s=2 then e=2
                    else e=3
      when r=2 then if s=3 then e=2
                    else e=3
      when r=3 then if s=2 then e=3
                    else e=2
      otherwise     if s=3 then e=3
                    else e=2
   end
   say erg.e
end
say "Bye, bye..."
exit
back to Fun & More