import java.applet.Applet; import java.awt.event.*; import java.awt.*; import java.io.*; import java.util.*; public class hiirega extends Applet implements ActionListener{ int x=0, y=0; int mx[]=new int[4]; int my[]=new int[4]; int m[]=new int[4]; int klops=0; int kus=0;//mitmes on lühim väärtus massiivis int pikim=600; double ex=0, tex=0, kox=0, nex=0; double ey=0, tey=0, koy=0, ney=0; double ep=0, tep=0, kop=0, nep=0; public hiirega(){ addMouseListener(new HiireKuular()); } public void joonista(){ Graphics ekraan=getGraphics(); setBackground(Color.white); ekraan.setColor(Color.black); ekraan.drawOval(x, y, 30, 30); } public void lahimring(){ Graphics ekraan=getGraphics(); setBackground(Color.white); ekraan.setColor(Color.black); ekraan.fillOval(mx[kus], my[kus], 30, 30); } class HiireKuular extends MouseAdapter{ public void mousePressed(MouseEvent e){ if(klops<4){ x=e.getX(); mx[klops]=x; y=e.getY(); my[klops]=y; joonista(); System.out.println(""+mx[klops]+","+my[klops]); } klops++; if(klops>4){ x=e.getX(); y=e.getY(); System.out.println(""); System.out.println(""+x+","+y); //vektori x-koordinaadid ex=x-mx[0]; tex=x-mx[1]; kox=x-mx[2]; nex=x-mx[3]; //vektori y-koordinaadid ey=y-my[0]; tey=y-my[1]; koy=y-my[2]; ney=y-my[3]; //vektoripikkused m[0]=(int)Math.sqrt(ex*ex+ey*ey); m[1]=(int)Math.sqrt(tex*tex+tey*tey); m[2]=(int)Math.sqrt(kox*kox+koy*koy); m[3]=(int)Math.sqrt(nex*nex+ney*ney); for(int i=0;i<4;i++){ if(m[i]