package FOExperiment;

import java.applet.*; 
import java.awt.*; 

/*###################################################*/

// This base class illustrates a simple example 
// of inheritance for drawing different shapes. 
abstract class objectToDraw { 
  int centerX,centerY; // Center of drawn object 
  int drawX,drawY;     // Origin of object drawing area, 
                       //  e.g. top left corner of the 
                       // bounding  rectangle. 
  int dx,dy;           // Width of drawing area. 
  int areaX,areaY;     // Dimensions of the applet
                       //  drawing area. 
  Color color; 

  double Vtot=0.2;
  double Vx,Vy;
  double toggleSign=1.0;
/*---------------------------------------------------*/
  objectToDraw(int centerX, int centerY, int dx, int dy,
                int dX, int dY){ 
    this.centerX  = centerX; 
    this.centerY  = centerY; 
    this.dx = dx; 
    this.dy = dy; 

    drawX = this.centerX - (dx/2); 
    drawY = this.centerY - (dy/2); 

    areaX=dX; 
    areaY=dY; 

    color = Color.red; 

    // Initialize the velocity of the object.
    Vtot = Vtot*Math.random()+0.1;
    Vx = Vtot*Math.random()+0.01;
    if(Vx >= Vtot) Vx = Vtot-0.2;
    if(Vx <= 0.05) Vx = 0.1;
    Vy = Math.sqrt( Vtot * Vtot - Vx*Vx);
  } 
/*---------------------------------------------------*/
  abstract public void move(double deltaT);
/*---------------------------------------------------*/
// This abstract method will be overridden by the sub-classes

  abstract public void draw(Graphics g);
} 