///Tye jamison // Project 8 and final // float black=0; //STRINGS FOR ARRAY// String names[]= { "Tye", "GrandPa", "Sam", "sterlin", "corey", "Wes", "Alex", "Gianna", "Big Wes", "Troy"}; String columns[]= { "NAMES", "AGE", "WEIGHT", "HEIGHT", "BMI","wtdiff"}; int age[]= {20, 84, 40, 21, 17, 22, 19, 24, 43, 38, 45}; int weight[]= { 130, 156, 187, 109, 210, 148, 115, 123, 203, 99}; int ht[]= { 66, 72, 78, 51, 60, 70, 80, 49, 67, 63, 66, 55, 44 }; int BMI[]={ 51, 45 , 32, 12, 48, 56, 23, 45, 12, 78, 56, 25 }; int wtdiff[]={18,8,40,-31,68,20,35,22,78,49}; int many= names.length; //Member[] family= new Member[many]; // Create array of family members. void setup() { smooth(); size(1000,900); } void draw() { //// Next frame //// background(255,140,0); drawtable(); screentext(); info(); textSize(20); text( "The last key you pressed was " + key, 20, 50 ); textSize(12); text( "Press keys a, w, h, or n to sort by age, wt, ht, or name", width/2, height-30); text( "Press q key to quit.", width/2, height-10); } //info void screentext() { fill(black); textSize(13); text("Tye Jamison",10,20); text("Project 8",600,45); textSize(30); text("Table",370,90); } //TABLE THAT WILL HOLD INFO// void drawtable() { fill (0,0,255); stroke(black); strokeWeight(3); rect (100, 100, 600, 330); //VERTICALE LINES -- ARRAY FOR NAMES// strokeWeight(2); stroke(black); int n=0; for (int y= 130; y<430; y= y+30){ fill(black); line(100, y, 700, y); textSize(15); text(""+names[n], 110, y+20); n= n+1; } //HORIZONTLE LINES -- ARRAY FOR COLUMNS// strokeWeight(2); stroke(black); int c=0; for (int x= 100; x<700; x= x+120){ line(x, 100, x, 430); textSize(15); text(""+columns[c], x+20, 120); c= c+1; } } //INFORMATION ON THE CHART// void info() { //WEIGHT & HEIGHT // int w=0; for (int y= 130; y<430; y= y+30){ fill(black); textSize(12); text(""+weight[w], 390, y+20); text(""+ht[w], 490, y+20); w= w+1; } //Age for (int y= 130, a=0; y<430; y=y+30, a= a+1 ){ fill(black); textSize(12); text(""+age[a], 270, y+20); //BMI for (int z= 130, B=0; z<430; z=z+30, B= B+1 ){ fill(black); textSize(12); text(""+BMI[B], 600, z+20); //weight diff for (int e= 130, wd=0; e<430; e=e+30, wd= wd+1 ){ fill(black); textSize(12); text(""+wtdiff[wd], 750, e+20); } } } } void keyPressed() { //handle key event// if ( key == 'a' ) { sortby( age, many ); } if ( key == 'w' ) { sortby( weight, many ); } if ( key == 'h' ) { sortby( ht, many ); } if ( key == 'n' ) { sortby( names, many ); } if ( key == 'q' ) { exit(); } } void sortby( int[] a, int many ) { //// Sort all, using a[] as "key" //// Find greatest age, move to end. int m; int w; //// Sort (by finding max & swapping it to [m-1] for (m=many; m>1; m-- ) { w=0; //// Index of biggest for (int i=1; i a[w]) w=i; } swapall( w, m-1 ); } } void sortby( String[] s, int many ) { //// Sort all, using String array s[] as "key" //// Find greatest age, move to end. int m; int w; //// Sort (by finding max & swapping it to [m-1] for (m=many; m>1; m-- ) { w=0; //// Index of biggest for (int i=1; i s[w]) w=i; if ( s[i].compareTo(s[w]) > 0 ) w=i; //// Index of biggest, so far } swapall( w, m-1 ); } } void swapall( int j, int k ) { //// Swap all parallel arrays //// swap( names, j, k ); swap( age, j, k ); swap( weight, j, k ); swap( ht, j, k ); } void swap( int[] a, int j, int k ) { //// Swap two int elements of array a[] // a[j] gets a[k] and vise versa int temp; temp= a[j]; a [j] = a[k]; a[k]= temp; } void swap( String[] a, int j, int k ) { //// Swap two String elements of array a[] // a[j] gets a[k] and vise versa String temp; temp= a[j]; a [j] = a[k]; a[k]= temp; } //////separate // I was trying implement something for the bird to go down from top to bottom shakeing. it runs if you place the bird tab into a separate class. I was trying to have it over the table // The size of the output window //int mySize = 400; // Declare six objects from class Triangles //Triangles triangle1; //Triangles triangle2; //Triangles triangle3; //Triangles triangle4; //Triangles triangle5; //Triangles triangle6; // Set size of output window and instantiate six triangle objects //void setup() //{ //size(400, 400); //smooth(); //triangle1 = new Triangles(); //triangle2 = new Triangles(); //triangle3 = new Triangles(); //triangle4 = new Triangles(); //triangle5 = new Triangles(); // triangle6 = new Triangles(); //} //void draw() //{ // background(255); // drawBackground(); // triangle1.display(); /// triangle1.move(); // triangle1.boundaries(); // triangle1.reset(); // triangle2.display(); // triangle2.move(); // triangle2.boundaries(); //triangle2.reset(); //triangle3.display(); //triangle3.move(); //triangle3.boundaries(); //triangle3.reset(); // //triangle4.display(); //triangle4.move(); //triangle4.boundaries(); //triangle4.reset(); // //triangle5.display(); /// triangle5.move(); //triangle5.boundaries(); //triangle5.reset(); //triangle6.display(); //triangle6.move(); //triangle6.boundaries(); // triangle6.reset(); //} //void drawBackground() //{ // fill(255,255,150); //rect(0,0,200,200); //fill(255,150,255); // rect(0,200,200,400); // rect(200,0,400,200); // fill(150,255,255); //rect(200,0,400,200); // fill(150); //rect(200,200,400,400); //} //class Triangles //{ // //float x; //float y; // The speed // float speed; // The random RGB fill color variables // int r; // int g; //int b; // Triangles() // { // x = random(30 , width - 30); // y = 0; // speed = random(1, 5); // r = (int) random(255); // g = (int) random(255); //b = (int) random(255); //} // void display() //{ //fill(r,g,b,75); // for (float ctr = 0; ctr <= 12; ctr++) // triangle(x+ctr, y+ctr, x+ (ctr - 15), y + (ctr + 30), x + (ctr + 15), y + (ctr + 30)); // } //void move() //{ // x = x + random(-2,2); ///y = y + speed; //} //void boundaries() //{ // constrain(x,0,width); // } // void reset() //{ // if (y >= height) // y = 0; //} //}