import java.awt.*; import java.applet.Applet; import java.awt.event.*; //nupuvajutus public class Kolmnurk1 extends Applet implements ActionListener{ TextField tfa=new TextField("50"); TextField tfb=new TextField("50"); TextField tfc=new TextField("50"); Button nupp=new Button("Joonista"); public Kolmnurk1(){ add(new Label("Esineme kulg")); add(tfa); add(new Label("Teine kulg")); add(tfb); add(new Label("Kolmas kulg")); add(tfc); add(nupp); nupp.addActionListener(this); } public void paint(Graphics g){ int algX=150; //1 punkt int algY=100; //1 punkt int a=Integer.parseInt(tfa.getText()); int b=Integer.parseInt(tfb.getText()); int c=Integer.parseInt(tfc.getText()); if (c+b>a){ if (a+c>b){ if (b+a>c){ int X2=a*a+c*c-b*b; double algX2 = X2/(2*c); int k=0; for (int n=0; algX2>0; n++) { algX2=algX2-1; k=k+1; } if (algX2>0.5) k=k+1; int Y2=((a+b+c)*(a+c-b)*(b+a-c)*(b+c-a)/(4*c*c)); double algY2= Math.sqrt (Y2); int i=0; for (int t=0; algY2>0 ; t++) { algY2=algY2-1; i=i+1; } if (algY2>0.5) i=i+1; g.setColor(new Color(100, 100, 100)); g.setColor(Color.blue); g.drawLine(150, 100, 150+c, 100); g.drawLine(150, 100, 150+k, 100+i); g.drawLine(150+c, 100, 150+k, 100+i); } } } } public void actionPerformed(ActionEvent e){ repaint(); //uuenda joonis } public static void main(String[] argumendid){ Frame f=new Frame("Kolmnurk1"); f.setSize(500, 300); f.setBackground(new Color(252, 241, 222)); f.add(new Kolmnurk1()); f.setVisible(true); } }