import java.awt.Color; import java.awt.Graphics; import java.awt.geom.Rectangle2D; public class Wall { private Rectangle2D.Double rect; private Color color; private int x,y,width,height; public Wall(int x, int y, int width, int height){ rect=new Rectangle2D.Double(x, y, width, height); this.x=x; this.y=y; this.width=width; this.height=height; setColor(Color.BLACK); } public boolean touches(Ball ball){ return rect.intersects(ball.area()); } public void draw(Graphics g){ Color c=g.getColor(); g.setColor(color); g.fillRect(x, y, width, height); g.setColor(c); } public void setColor(Color color) { this.color = color; } public Color getColor() { return color; } }