import papaya.*; import guicomponents.*; Study aStudy; PFont myfont, myboldfont; PImage smallleft, smallup, smalldown, smallright; PImage hyp0, hyp1, hyp2, hyp3, zu, zl, p1, p2, p3; GCombo cb1, cb6; GTextField tf2, tf3; JakeButton leftarrow, rightarrow, ans; String[] str1 = { "Yes", "No" }; String[] str6 = { "Reject Ho", "Cannot reject Ho" }; int page = 1, score; float testu, testl, pu, pl, pvalue; boolean[] answered = { false, false, false, false, false, false }; String[] answers = { "", "", "", "", "", "" }; float[] graphdata; PGraphics pg; int gwidth=160, gheight=80; String feedback = ""; void setup() { size(700, 500); smooth(); loadData(); aStudy = new Study(); graphdata = new float[101]; for (int i = 0; i < 101; i++) { float x = -3.0 + 0.06*i; graphdata[i] = exp(-x*x/2)/sqrt(2*PI); } pg = createGraphics(gwidth, gheight, P2D); cb1 = new GCombo(this, str1, 3, 80, 300, 50); cb6 = new GCombo(this, str6, 6, 80, 300, 150); tf2 = new GTextField(this, "", 200, 330, 100, 20, false); tf3 = new GTextField(this, "", 470, 330, 100, 20, false); PImage[] ansset = {loadImage("answerdark.jpg"),loadImage("answerlight.jpg")}; ans = new JakeButton(200,430,ansset[1],ansset[0],ansset[0]); PImage[] lefts = {loadImage("leftblue.jpg"), loadImage("leftpurple.jpg")}; leftarrow = new JakeButton(30,415,lefts[1],lefts[0],lefts[0]); PImage[] rights = {loadImage("rightblue.jpg"), loadImage("rightpurple.jpg")}; rightarrow = new JakeButton(615,415,rights[1],rights[0],rights[0]); } void draw() { background(255); fill(0); generateProblem(); switch(page) { case 1: page1(); break; case 2: page2(); break; case 3: page3(); break; case 4: page4(); break; case 5: page5(); break; case 6: page6(); break; } fill(255, 0, 0); text("Score: " + score + " / 60", 450, 460); if (answered[5]) text("Final", 405, 460); leftarrow.updateButton(); leftarrow.drawButton(); if (leftarrow.clicked) { feedback = ""; tf2.setText(""); tf3.setText(""); page--; if (answered[page-1]) feedback = "You answered this question with " + answers[page-1]; } rightarrow.updateButton(); rightarrow.drawButton(); if (rightarrow.clicked) { feedback = ""; tf2.setText(""); tf3.setText(""); if (answered[page-1]) { page++; } else { feedback = "You have to answer this question before continuing."; } if (page>6) { page = 1; aStudy = new Study(); score = 0; answered = new boolean[] { false, false, false, false, false, false }; } if (answered[page-1]) feedback = "You answered this question with " + answers[page-1]; } ans.updateButton(); ans.drawButton(); if (ans.clicked) { if (!answered[page-1]) response(); else feedback = "You answered this question with " + answers[page-1]; } }