hello!
this is medium hard...
you could make a 2D array with math equation+ right answer or 2 parallel 1D arrays
- // a quiz
- String[] questions = {
- "question 1", "question 2", "question 3", "question 4", "question 5"
- };
- String[] rightAnswer = {
- "answer Right1", "answer Right 2", "answer Right 3", "answer Right 4", "answer Right 5"
- };
Then have a class Cloud with an image and math equation and you load in setup() and steer its behaviour.
Probably arraylist of Cloud.
Have a function mouseClicked
- void mouseClicked() {
- println("clicked");
- }
and check if you clicked within a cloud
then get the answer from user, check equality
How to input an answer
- //For user input dialogs
- import javax.swing.JOptionPane;
- void setup () {
- // do init here
- }
- void draw() {
- // do program here
- }
- void mouseClicked() {
- println("clicked");
- String y = JOptionPane.showInputDialog(null,
- "Your answer:",
- "Math question 3+7",
- JOptionPane.PLAIN_MESSAGE);
- println(y);
- if (y.equals("10"))
- println("Correct");
- else
- println("Wrong.");
- }
If the answer is correct, the cloud disappears. If the answer is incorrect, the cloud turns red and the text changes to white.
Greetings, Chrisir