Having trouble creating Guessing Game with sequences

It’s very easy to do with flowcharts, but the exercise also asked to do it with sequences and I’m having a bit of trouble here.

I can get it to work fine, but after guessing the number correctly and the user picks “stop”, I want the program to completely stop instead of going on forever generating new ones. How do I do that?

Attaching below my workflow for ease of reference.Guessing Game with Sequences.xaml (12.7 KB)

Hello friend,

Since you are using Flowchart i would suggest to use Flow Decision Activity for decisions instead of using multiple IF statements because this is not the best practice.

From what i can see you don’t have the Rule when user types ‘Stop’ the game will stop.
I’ve attached some workflow (idk if it works) but it shows you how you can make this.

Guessing Game with Sequences.xaml (17.1 KB)

p.s. I edited the xaml file because i forgot to change UserInput variable to int32

Hi,

As I said above, I know this is easier with flowcharts and decision activities, but I want to do it with sequences, for the purpose of learning, as the exercise asked. I don’t have a rule when use types “Stop” because this is my question :stuck_out_tongue: I don’t know what rule to use to make it stop.

The problem is that Sequence activity is used for processes that are going one after another (in a sequence), that is why there is only one Output from them. There is no point in trying it this way because it is a bad practice. If you really want to do this, i would put only one Sequence activity at the beginning and inside of it i would put the rest, with some While or Do While activities to repeat the process.

Guessing Game with Sequences.xaml (17.1 KB)

Here, use While loop, it is much cleaner

Yeah I’m not sure this would work with a sequence. I’ve tried with While and Do While, but the bottom line is I cannot get back out to re-evaluate another guess (stuck in the loop). I’m moving on!

Assign -> Input from user -> While random no <> userinput -> if condition for lower or higher no (if loop closes here)

Then input again to get the number, (still inside the while loop) ,

Finally Correct guess message outside the while loop

(i am not able to upload the file as a new user ) i am posting the picture

2 Likes

Can be done in Do While loop.
Please find attached xaml containing the logic required. let me know if that helps you or not. Main.xaml (16.4 KB)

Hell yeah! I’ve been thinking about that answer for an hour! Thanks!