/* Moving Ball */ import java.awt.*; public class Ball { public double x,y,radius; public double vx,vy; public Color Fillin_Color; public Color colorFromString (String s, Color defaultColor) { Integer i; if (s == null) return defaultColor; try { i = Integer.valueOf(s,16); return new Color(i.intValue()); } catch (NumberFormatException e) { if (s.equalsIgnoreCase("red")) { return Color.red; } else if (s.equalsIgnoreCase("green")) { return Color.green; } else if (s.equalsIgnoreCase("blue")) { return Color.blue; } else if (s.equalsIgnoreCase("black")) { return Color.black; } else if (s.equalsIgnoreCase("white")) { return Color.white; } else if (s.equalsIgnoreCase("gray")) { return Color.lightGray; } else { return defaultColor; } } } public Ball() { radius = 5.0; x = radius; y = radius; vx = 100.0; vy = 100.0; Fillin_Color = Color.black; } public Ball (double x, double y, double radius, double vx, double vy, String Fillin_Color) { this.x = x; this.y = y; this.vx = vx; this.vy = vy; this.radius = radius; this.Fillin_Color = colorFromString(Fillin_Color,Color.black); } }