import java.awt.*;
import java.awt.geom.*;

public class Thing
{
  double x,y,dx,dy;

  public Thing(double iX, double iY, double iDX, double iDY)
  {
    x = iX; y = iY; dx = iDX; dy = iDY;
  }

  public void move(Rectangle b) 
  { 
    x += dx; y += dy; 
    if (x <= 0 || x >= b.getWidth())  { dx *= -1; x += 2*dx; }
    if (y <= 0 || y >= b.getHeight()) { dy *= -1; y += 2*dy; }
  }

  public void paint(Graphics2D g) 
  { 
    g.fill(new Ellipse2D.Double(x,y,10,10)); 
  }
}