Modify a text file: $/pagan.java
$/pagan.java
//William Pagan //CST112 ///Fish Tank class Fish { //Prepairing Fish class. float x=75, y=75, dx=3, dy=1, w=60, h=25 ; int r,g,b; //colors for fishes. String name=""; void show() { //Drawing my fish. fill(r,g,b); ellipse( x ,y, w ,h ); float front=x+w/2,back=x-w/2; if (dx>0){ triangle( back,y, back-20,y-10, back-20,y+10 ); }else{ triangle (front,y, front+20,y-10, front+20,y+10); } float eye; eye= (dx>0) ? front-15 : back+15; fill(255); //eyes of the fish. strokeWeight(1); ellipse (eye,y-10, 10, 10); text (name, x-10, y); } void move(){ // the move routine. if (x>right || x
bottom || y
this.x/+2) return false; if (y
this.y+h/2)return false; return true; } Fish(){}; //Constuctor// Fish( String s ) { name=s; restart(); } void restart() { x= random(left,right); // randomizing position of fishes. y= random(top,bottom); dx= random(0.5,5); w= random(20,120); // randomizing the sizes. h= random(20,50); r= int ( random(255) ); // randomizing colors of the fishes. g= int ( random(255) ); b= int ( random(255) ); }//End class Fish// } class Button { //Buttons. } //Declaring "globals". float left=50, top=50, right=750, bottom=550; Button b1; Fish tuna; Fish guppy; Fish koi; Food[] crud; int numFood=10; void setup() { //Setting up screen size. size (800,600); reset(); } void reset() { tuna= new Fish(); tuna.name= "Tuna"; //Naming my fish. tuna.y=100; tuna.r= 255; // guppy= new Fish(); guppy.name= "Guppy"; guppy.y=200; guppy.g= 200; // koi= new Fish(); koi.name= "Koi"; koi.y=300; koi.b= 151; b1= new Button(); //// Create crud array of food. numFood= int( random( 1, 20 ) ); crud= new Food[ numFood ]; for (int i=0; i