import java.awt.Graphics; class Kujund{ int x, y, dx, dy; String tyyp; public Kujund(int ux, int uy, int ur){ x=ux; y=uy; dx=ur*2; dy=ur*2; tyyp="ring"; } public Kujund(int ux, int uy, int kx, int ky){ x=ux; y=uy; dx=kx; dy=ky; tyyp="ristkylik"; } void joonista(Graphics g){ if(tyyp.equals("ring")){ g.drawOval(x-dx/2, y-dy/2, dx, dy); } else { g.drawRect(x, y, dx, dy); } } void paiguta(int ux, int uy){ x=ux; y=uy; } boolean kasPihtas(int hx, int hy){ if(tyyp.equals("ring")){ int mx=hx-x, my=hy-y; if(Math.sqrt(mx*mx+my*my)x+dx){return false;} if(hyy+dy){return false;} return true; } } }