# Any idea how to fix this? Quiz

**URL:** https://discourse.processing.org/t/any-idea-how-to-fix-this-quiz/15418
**Category:** Coding Questions
**Tags:** homework
**Created:** [November 12, 2019, 10:15am UTC](https://discourse.processing.org/t/any-idea-how-to-fix-this-quiz/15418 "2019-11-12T10:15:15Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [November 12, 2019, 9:07pm UTC](https://discourse.processing.org/t/any-idea-how-to-fix-this-quiz/15418/6 "2019-11-12T21:07:51Z")

</div>

here is a working version. There were a lot of small things to fix.

(as I said: Arrays)

Chrisir

```auto

int flag = 0;

void setup() {
  size( 1366, 768);
  background(255);
}//func 

void draw() {
  background(255);
  actOnFlag();
}//func 

// -------------------------------------------------

void actOnFlag() {
  if (flag == 0) {
    // Question 1
    pushStyle();
    background(255);
    fill(255, 0, 0);
    rect (700, 300, 300, 300);
    fill(0, 255, 0);
    rect (300, 300, 300, 300);
    fill(0, 0, 0);
    text("1. Aussage:", 600, 150);
    text("Wir haben einen nicht gelisteten Helfer.", 350, 190);
    textSize(32);
    fill(0, 51, 0);
    text("WAHR", 400, 450);
    textSize(32);
    fill( 128, 0, 0);
    text("FALSCH", 800, 450);
    popStyle();
  } else if (flag == 1) {
    // Correct 
    pushStyle();
    background(255);
    fill(0, 255, 0);
    textSize(42);
    text("Richtig!", 600, 150);
    fill(0);
    rect(600, 300, 300, 300);
    textSize(32);
    fill(255);
    text("Nächste", 700, 400);
    text("Aussage->", 700, 450);
    popStyle();
  } else if (flag == 2) {
    // Wrong 
    pushStyle();
    background(255);
    fill(255, 0, 0);
    text("Falsch!", 600, 150);
    fill(0);
    rect(600, 300, 300, 300);
    textSize(32);
    fill(255);
    text("Nächste", 700, 400);
    text("Aussage->", 700, 450);
    popStyle();
  } else if (flag == 3) {
    // Question 2
    pushStyle();
    background(255);
    fill(255, 0, 0);
    rect (700, 300, 300, 300);
    fill(0, 255, 0);
    rect (300, 300, 300, 300);
    fill(0, 0, 0);
    text("2. Aussage:", 600, 150);
    text("Wir sind das erste Mal dabei.", 350, 190);
    textSize(32);
    fill(0, 51, 0);
    text("WAHR", 400, 450);
    textSize(32);
    fill( 128, 0, 0);
    text("FALSCH", 800, 450);
    popStyle();
  } else {
    background(255);
    fill(255, 0, 0);
    text("Else: "+flag, 600, 150);
  }
}//func 

// -------------------------------------------------

void mousePressed() {
  println("MouseX: " + mouseX + " MouseY: " + mouseY + " Flag: " + flag);

  if (flag == 0) {
    // Question 1
    if (mouseX>300 && mouseX < 600 && mouseY >300 && mouseY <600) {
      flag = 1;
    }
    if (dist(mouseX, mouseY, 849, 450)<125) {
      flag = 2;
    }
  }
  //------------------------
  // Two result screens with a "Next button"
  else if (flag == 1) {
    // Correct 
    if (mouseX>600 && mouseX < 900 && mouseY >300 && mouseY <600) {
      flag = 3; // both proceed to Question 2
    }
  } else if (flag == 2) {
    // Wrong 
    if (mouseX>600 && mouseX < 900 && mouseY >300 && mouseY <600) {
      flag = 3; // both proceed to Question 2
    }
  } 
  //---------------------
  else if (flag == 3) {
    // Question 2
    if (mouseX>300 && mouseX < 600 && mouseY >300 && mouseY <600) {
      flag = 4;
    }
    if (dist(mouseX, mouseY, 850, 450)<125) {
      flag = 5;
    }
  }//if
  //--------------------
  else {
    // flag = 0;
  }
  //
}//func 
//

```

---

_[View the full topic](https://discourse.processing.org/t/any-idea-how-to-fix-this-quiz/15418)._
