UserPreferences

InClassExample


public class Air extends Applet {
        
        //Balloon happy;
        Balloon sad;
        Balloon array[];
        
        public Air () { 
                array = new Balloon[99];
                
                for(int i = 0; i < 99; i++) {
                        array[i] = new Balloon(Color.red, 
                                               (int) (Math.random() * 500),
                                               (int) (Math.random() * 500) );
                }
                
                //happy = new Balloon(Color.red, 100, 100); 
        
                sad = new Balloon(Color.blue, 200, 200);
        
        }
        
        public void paint (Graphics g) {

                for(int i = 0; i < 99; i++) {
                        array[i].inflate(g); 
                }
                //happy.inflate(g);
                
                sad.inflate(g); 
                
                
        }
        
        
        
}

import java.awt.*;


public class Balloon { 
        
        Color color;
        int x;
        int y;
        
        
        public Balloon(Color c, int a, int b) {
                
                color = c;
                x = a;
                y = b;
                
        }
        
        
        public void inflate (Graphics g) {
                
                g.setColor(color);
                g.fillOval(x, y, 25, 25);
                g.setColor(Color.black);
                g.drawLine(x+13, y+25, x+13, y+50);
                
                

                
        }
        
        
        
        
        
        
}