# Hello i made some quiz and i can only change 2 page if anyone can show me how can ı reset the page

**URL:** <https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424>\
**Category:** Coding Questions\
**Created:** [December 21, 2020, 5:37pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424 "2020-12-21T17:37:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![clay21](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@clay21](https://discourse.processing.org/u/clay21)\
**Post date:** [December 21, 2020, 5:37pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/1 "2020-12-21T17:37:31Z")

</div>

int page=0;  
void setup(){  
size(800,600);  
page+=1;

}  
void draw(){  
switch(page){  
case 1:drawPage1();break;  
case 2:drawPage2();break;  
case 3:drawPage3();break;  
case 4:drawPage4(); break;  
default:break;  
}

}

void drawPage1(){  
background(0);textSize(15);  
fill(255);  
text("Jenneferin babasının 3 kızı vardır KızlarınınA adı Lili ve Lulu’dur 3. ismi nedir ",0,100);

if(mouseX\>150 && mouseY\>400 && mouseX\<250 && mouseY\<450 && mousePressed==true){  
fill(42,255,15);  
rect(150,400,100,50);  
fill(255,0,0 );  
rect(300,400,100,50);  
setup();  
drawPage2();

}  
else if(mouseX\>300 && mouseY\>400 && mouseX\<400 && mouseY\<450 && mousePressed==true){

```
fill(255,0,0 );

```

rect(300,400,100,50);  
fill(42,255,15);  
rect(150,400,100,50);  
setup();  
drawPage2();

}

else {  
fill(324,0,115);  
rect(150,400,100,50);  
fill(42,125,1512);  
rect(300,400,100,50);  
fill(255);  
text(“Jennifer”,185,430);  
text(“Lala”,340,430);

}

}  
void drawPage2(){

background(0); textSize(15);  
fill(255);  
text(“5 Katlı binanın son katına çıkmak için kaç merdiven çıkmak gerekir”,0,100);

if(mouseX\>150 && mouseY\>400 && mouseX\<250 && mouseY\<450 && mousePressed==true){  
fill(42,255,15);  
rect(150,400,100,50);  
fill(255,0,0 );  
rect(300,400,100,50);  
setup();  
drawPage3();

}  
else if(mouseX\>300 && mouseY\>400 && mouseX\<400 && mouseY\<450 && mousePressed==true){

```
fill(255,0,0 );

```

rect(300,400,100,50);  
fill(42,255,15);  
rect(150,400,100,50);  
setup();  
drawPage3();

```
}

```

else {  
fill(324,0,115);  
rect(150,400,100,50);  
fill(42,125,1512);  
rect(300,400,100,50);  
fill(255);  
text(“6”,185,430);  
text(“5”,340,430);

}

}  
void drawPage3(){  
textSize(15);  
fill(255);  
text(“ANAN”,0,100);

if(mouseX\>150 && mouseY\>400 && mouseX\<250 && mouseY\<450 && mousePressed==true){  
fill(42,255,15);  
rect(150,400,100,50);  
fill(255,0,0 );  
rect(300,400,100,50);

}  
else if(mouseX\>300 && mouseY\>400 && mouseX\<400 && mouseY\<450 && mousePressed==true){

```
fill(255,0,0 );

```

rect(300,400,100,50);  
fill(42,255,15);  
rect(150,400,100,50);

}

else {  
fill(324,0,115);  
rect(150,400,100,50);  
fill(42,125,1512);  
rect(300,400,100,50);  
fill(255);  
text(“62”,185,430);  
text(“123”,340,430);

}

}

void reset(){

setup();

}  
void drawPage4(){  
textSize(15);  
fill(255);  
text(“ANAN AND BACIN”,0,100);

if(mouseX\>150 && mouseY\>400 && mouseX\<250 && mouseY\<450 && mousePressed==true){  
fill(42,255,15);  
rect(150,400,100,50);  
fill(255,0,0 );  
rect(300,400,100,50);

}  
else if(mouseX\>300 && mouseY\>400 && mouseX\<400 && mouseY\<450 && mousePressed==true){

```
fill(255,0,0 );

```

rect(300,400,100,50);  
fill(42,255,15);  
rect(150,400,100,50);

}

else {  
fill(324,0,115);  
rect(150,400,100,50);  
fill(42,125,1512);  
rect(300,400,100,50);  
fill(255);  
text(“62”,185,430);  
text(“123”,340,430);

}  
}

---

<div class="post-metadata">

**Author:** ![jay\_m](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jay_m/32/11020_2.png) [@jay\_m](https://discourse.processing.org/u/jay_m)\
**Post date:** [December 21, 2020, 5:53pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/2 "2020-12-21T17:53:03Z")

</div>

Please use code tags

You should not call setup() when the right answer is provided, you should just increment your page index and the switch will draw the next quizz. If at the end of quizz 4 you want to go back to the first quizz, just set the page number to 1

---

<div class="post-metadata">

**Author:** ![clay21](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@clay21](https://discourse.processing.org/u/clay21)\
**Post date:** [December 21, 2020, 6:22pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/3 "2020-12-21T18:22:30Z")

</div>

When I try to switch from drawPage2 to drawPage3 drawPage2 does not disappear from the screen can you show me the true please I’ve been trying to do this for 2 days

---

<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:** [December 21, 2020, 7:12pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/4 "2020-12-21T19:12:22Z")

</div>

At start of draw() always say background…

---

<div class="post-metadata">

**Author:** ![clay21](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@clay21](https://discourse.processing.org/u/clay21)\
**Post date:** [December 21, 2020, 7:42pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/5 "2020-12-21T19:42:50Z")

</div>

it definitely changed something thank you , but after printing 2 pages every time, I can’t switch to 3 please can someone do it and show it please

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 21, 2020, 8:18pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/6 "2020-12-21T20:18:43Z")

</div>

here is my code! I did it for fun, so you probably won’t learn too much from it. I blured it so you don’t have to see it!

```auto
ArrayList<String[]> questions = new ArrayList<String[]>();
ArrayList<Integer> cAnswer = new ArrayList<Integer>();
int cq = 0, bSize = 40;
String ans[] = {"a","b","c","d","e","f","g"};

void setup() {
  size(600,600);
  String q[] = {"What is 1 + 2 ?","a) two ","b) three ", "c) four ", "d) five"};
  questions.add(q);
  cAnswer.add(3); //third item on q[] list 
  
  String q2[] = {"What is 2 * 3 ?","a) four ","b) five ", "c) six ", "d) seven", "e) eight"};
  questions.add(q2);
  cAnswer.add(4);
  
  String q3[] = {"What is this program's creator Processing-forum name?", "a) Nick ", "b) Paul ", "c) CodePro69 ", "d) CodeMasterX", "e) Jeff Jefferson"};
  questions.add(q3);
  cAnswer.add(5);
  
  String q4[] = {"This will be the end no buttons will work anymore", "a) why? ", "b) cuz I'm lazy", "c) farewell"};
  addQuestion(q4,-1);
  
  textAlign(3,3);
}

void draw() {
  background(0);
  fill(255);
  String cQ[] = questions.get(cq);
  text(cQ[0],width/2,50);
  for(int i = 0; i < cQ.length-1; i ++) {
    text(cQ[i+1],width/2,100+i*30);
  }
  for(int i = 0; i < cQ.length; i++) {
    noFill();
    stroke(255);
    circle(map(i,0,cQ.length-2,width/8,width/8*7),height/2,bSize);
    fill(255);
    text(ans[i],(map(i,0,cQ.length-2,width/8,width/8*7)),height/2);
  }
}

void mousePressed() {
  for(int i = 0; i < questions.get(cq).length;i++) {
    if(dist(mouseX,mouseY,(map(i,0,questions.get(cq).length-2,width/8,width/8*7)),height/2) < bSize) {
      if(i == cAnswer.get(cq)-2) {
        println("Correct!");
        cq++;
      } else {
        println("Incorrect");
      }
    }
  }
}

void addQuestion(String[] text, int correctAnswer) {
  questions.add(text);
  cAnswer.add(correctAnswer);
}

```

---

<div class="post-metadata">

**Author:** ![clay21](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@clay21](https://discourse.processing.org/u/clay21)\
**Post date:** [December 21, 2020, 8:26pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/7 "2020-12-21T20:26:50Z")

</div>

I’m definitely trying to do something like this but I don’t have enough information to do this. Can you browse mine? Why can’t I go to 3 pages?

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 21, 2020, 8:57pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/8 "2020-12-21T20:57:17Z")

</div>

the issue is with the drawPage3 it is due to skipping the 2nd since the answers are the same. Your system is flawed due to not using the

```auto
void mousePressed() {
   if(inBox) do something;
}

```

and the reason why you can’t see the 4th page is because you forgot to call the setup() in the 3rd page.

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 21, 2020, 8:57pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/9 "2020-12-21T20:57:55Z")

</div>

I modified it so it works a bit better. I still can’t sort it out because the code is a bit messy : P

```auto
int page=0;
boolean pressed = false;
void setup() {
  size(800, 600);
  page+=1;
  pressed = true;
}
void draw() {
  background(0);
  switch(page) {
  case 1:
    drawPage1();
    break;
  case 2:
    drawPage2();
    break;
  case 3:
    drawPage3();
    break;
  case 4:
    drawPage4(); 
    break;
  default:
    break;
  }
}

void drawPage1() {
  background(0);
  textSize(15);
  fill(255);
  text("Jenneferin babasının 3 kızı vardır KızlarınınA adı Lili ve Lulu’dur 3. ismi nedir ", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true && !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage2();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage2();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("Jennifer", 185, 430);
    text("Lala", 340, 430);
  }
}
void drawPage2() {

  background(0); 
  textSize(15);
  fill(255);
  text("5 Katlı binanın son katına çıkmak için kaç merdiven çıkmak gerekir", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage3();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage3();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("6", 185, 430);
    text("5", 340, 430);
  }
}
void drawPage3() {
  textSize(15);
  fill(255);
  text("ANAN", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("62", 185, 430);
    text("123", 340, 430);
    setup();
  }
}

void reset() {

  setup();
}
void drawPage4() {
  textSize(15);
  fill(255);
  text("ANAN AND BACIN", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("62", 185, 430);
    text("123", 340, 430);
  }
}

void mouseReleased() {
  pressed = false;
}

```

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 21, 2020, 9:06pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/10 "2020-12-21T21:06:22Z")

</div>

fixed it all. I don’t know the language so the answers might be weird

```auto
int page=0;
boolean pressed = false;
void setup() {
  size(800, 600);
  page+=1;
  pressed = true;
}
void draw() {
  background(0);
  switch(page) {
  case 1:
    drawPage1();
    break;
  case 2:
    drawPage2();
    break;
  case 3:
    drawPage3();
    break;
  case 4:
    drawPage4(); 
    break;
  }
}

void drawPage1() {
  background(0);
  textSize(15);
  fill(255);
  text("Jenneferin babasının 3 kızı vardır KızlarınınA adı Lili ve Lulu’dur 3. ismi nedir ", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true && !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage2();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage2();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("Jennifer", 185, 430);
    text("Lala", 340, 430);
  }
}
void drawPage2() {

  background(0); 
  textSize(15);
  fill(255);
  text("5 Katlı binanın son katına çıkmak için kaç merdiven çıkmak gerekir", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage3();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage3();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("6", 185, 430);
    text("5", 340, 430);
  }
}
void drawPage3() {
  background(0); 
  textSize(15);
  fill(255);
  text("ANAN", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage3();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage3();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("62", 185, 430);
    text("123", 340, 430);
  }
}

void reset() {

  setup();
}

void drawPage4() {
  textSize(15);
  fill(255);
  text("ANAN AND BACIN", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("62", 185, 430);
    text("123", 340, 430);
  }
}

void mouseReleased() {
  pressed = false;
}

```

---

<div class="post-metadata">

**Author:** ![clay21](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@clay21](https://discourse.processing.org/u/clay21)\
**Post date:** [December 21, 2020, 9:21pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/11 "2020-12-21T21:21:56Z")

</div>

do you use any social media CodeMasterX

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 21, 2020, 9:39pm UTC](https://discourse.processing.org/t/hello-i-made-some-quiz-and-i-can-only-change-2-page-if-anyone-can-show-me-how-can-i-reset-the-page/26424/12 "2020-12-21T21:39:27Z")

</div>

nope. I am honestly not interested. I already have too many time-taking hobbies : P I never really understood social media, so I don’t have anything but my youtube account I use for watching yt
