I want to build "Which Harry Potter character are you?" app

Hello.
I want to build “Which Harry Potter character are you?” app, but don’t know how to link a different question for each choices, and get different ending.
( If Q1 ans a → Q2 → ans a → Q4 → ans a → Yes! you are Harry Potter.
____________________________–> ans b → you are Ron Weasley.
_______________ → ans b → Q5 …
_____ans b → Q3 → ans a → Q6 …
_______________–> ans b → Q2 …
like this)
Please help! I put some block together but cannot find a way to do so …T T
Thank you.

The fastest method i can think of is this:
I assume that you have many questions to ask in order, lets say A, B, C, D, E, F …
I also assume that every question has multiple answers, lets say 4 for each, like 1,2,3,4 (you can set question to a label, and answers to labeled buttons that once pressed will display you the next question and so on).
All you have to do is to define a variable (lets call it xANSERS) that will grow as answers are given:

  • before first quest xANSWERS=.null.
  • after first question will be xANSWERS=“1” (if user answered choosing 1st answer, for example)
  • after 2nd question will be xANSWERS=“13” (if user answered choosing 3rd answer, for example)
  • after 3rd question will be xANSWERS=“131” (if user answered choosing 1st answer… and so on
    After all questions have been anwered, you simple use some if else if block
    So, if xANSWERS =“1111…” then user is like …
    else if xANSWERS="1211… and so on…
1 Like

Great idea! Thank you so much. Very helpful. :+1: :+1: :+1:

Actually, what I tried to figure it out, is how to get to the next question in specific order depends on the answers.
For example:

  • Question : A B C D E F G … Z

  • Answer : 1 2 3 4

  • Ending answer : Harry Ron Hermione Dobby …

  • First Question will be A → if you answer 1 it will jump to question D, answer 2 jump to question B, answer 3 jump to question C, answer 4 jump to question F

  • Let’s say I choose ans 1 which jump to question D. And question D has 4 answers that will jump to the 4 different questions.

Second problem is how to get to the ending answer by your method.

  • if I do 10 question’s round, that make 4^10 ways of xANSWERS.

:thinking: :thinking: :thinking:
so confused right now :thinking:

Instead of thinking of it that way, you need to weight your answers. So for each question, the four answers each add a value to a running total. Let’s assume that for question A*, answer 1 is related to Harry and answer 2 is related to Hermione. If the user answers 1, you add 1 point to app variable HarryTotal. If the user answers 2, you add 1 point to app variable HermioneTotal, etc.

Then, when all of the questions are answered, you check to see which variable has the highest value and that is the character the user matched with. If there’s a tie, then you decide what to do (I would either announce that they matched two characters – it could be fun to provide a percentage for all four characters – or you just pick one at random to be the match).

Nope, I’d keep this really simple and just have a set of questions that you display in random order. No jumping around… just move the user through them straight from 1 to 10 or however many questions you end up having. The weighted answers above will take care of everything else.

*Personally, I’d recommend numbering the questions and using letters (if you even need them) for the answers. It’s confusing to me to think about the 4th question being “D” instead of just #4.

1 Like