Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Making decisions based on user string.
Old
kolz
Junior Member
 
Status: Offline
Posts: 10
Join Date: Dec 2013
Default Making decisions based on user string. - 12-29-2013, 12:12 AM

Bonus question on a previous assignment was to find a way to use a range of possible strings entered by user to re-run the program. I could not figure it out, but I would really like to know how to do it.

Any tips? Thanks
   
Reply With Quote
Old
Ygzaw
Junior Member
 
Status: Offline
Posts: 11
Join Date: Dec 2013
Default 12-29-2013, 01:07 AM

You can use the "either a or b, or both" function in the if else.
Let's say you have a string variable called abString. And you have a an object that needs to says YES if abString is "ab","aB","AB", or "Ab" and says NO when it is something else.

if true
object say YES...
else
object say NO

Replace 'true' by dragging function "either a or b, or both." Then replace 'a' and 'b' by abString== ab and by abString ==aB.

The above has covered the two possible strings to add the other two you can use two methods:
1 nesting another if else clause

if either abString == ab or abString == aB, or both
object say YES
[B]else[B]
if either abString == AB or abString == Ab, or both
object say YES
[B]else
object say NO

2 extend the logic
if either(either(either abString == ab or abString ==aB, or both) or abString == AB) or both) or abString == Ab, or both

object say YES
else
object say NO


I added the parenthesis for clarity.
I hope I have not complicated it more.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.