SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. final int NUMSTUDENTS=20;
  3.  
  4. int [] StudentMark;
  5. StudentMark=new int[NUMSTUDENTS];
  6.  
  7. for (int Index=0; Index<NUMSTUDENTS; Index++)
  8. {
  9.   StudentMark[Index]=0;
  10.   println(StudentMark[Index]);
  11. }
  12. */
  13.  
  14. /*
  15.  
  16. final int integerLenght=30;
  17. int [] integers;
  18. integers = new int[integerLenght];
  19.  
  20. int boolLenght=200;
  21. boolean [] booleans;
  22. booleans = new boolean[boolLenght];
  23.  
  24. int n=0;
  25. int arrayLenght=n;
  26. int [] infinity;
  27. infinity = new int[n];
  28.  
  29. */
  30.  
  31.  
  32. /*
  33.  
  34. final int BUTTONSIZE=50;
  35. final int NUMBUTTONS=5;
  36. boolean [] ButtonState;
  37.  
  38. void setup()
  39. {
  40.   size(650,300);
  41.   // create button state array
  42.   ButtonState=new boolean[NUMBUTTONS];
  43.  
  44.   // by default, the "origin" for ellipses is at the centre
  45.   // we can change this to the top-left corner, using ellipseMode(),
  46.   // which simplifies the button detection later on
  47.   ellipseMode(CORNER);
  48.  
  49.   // set all buttons to "off" (true==on, false==off)
  50.   for (int i=0; i<NUMBUTTONS; i++)
  51.     ButtonState[i]=false;
  52. }
  53.  
  54. void draw()
  55. {
  56.   // clear the background
  57.   background(0);
  58.  
  59.   // for each button...
  60.   for (int i=0; i<NUMBUTTONS; i++)
  61.   {
  62.     if (ButtonState[i]==true) // if it's "on"
  63.     {
  64.       fill(0,255,0); // green
  65.       stroke(0,255,0);
  66.     }
  67.     else // "off"
  68.     {
  69.       fill(255,0,0); // red
  70.       stroke(255,0,0);
  71.     }
  72.    
  73.     ellipse((i+1)*BUTTONSIZE*2, 100, BUTTONSIZE, BUTTONSIZE); // draw button
  74.   }
  75. }
  76.  
  77. void mouseClicked()
  78. {
  79.   // println("Mouse click at "+mouseX+", "+mouseY);
  80.  
  81.   // variable to store index of button that was pressed
  82.   int which=-1;
  83.  
  84.    // for each button...
  85.   for (int i=0; i<NUMBUTTONS; i++)
  86.   {
  87.     // calculate x and y position of top-left of button
  88.     int x=(i+1)*BUTTONSIZE*2;
  89.     int y=100;
  90.    
  91.     // if the mouse pointer is "inside" this button's region
  92.     if ((mouseX>=x && mouseX<=x+BUTTONSIZE) && (mouseY>=y && mouseY<=y+BUTTONSIZE))
  93.       // set the "which" variable to this button
  94.       which=i;
  95.   }
  96.  
  97.   // if we detected a click inside one of the buttons...
  98.   if (which != -1)
  99.   {
  100.     // flip that button's state
  101.     ButtonState[which]=!ButtonState[which];
  102.   }
  103. }
  104.  
  105. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top