// Linnuparv sümmeertiline. import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Linnud extends Frame implements ActionListener{ int nr; TextField tf=new TextField(" "+nr); Button nupp=new Button(" OK "); public Linnud(){ setLayout(new FlowLayout()); add(tf); add(nupp); nupp.addActionListener(this); setSize(600, 600); setVisible(true); } public void paint(Graphics g){ int i=1; int j=2; int k=25; int x=30*(10*i); int y=100; int xx=30*(10*i); int yy=100; if(nr%2==0){ for(; i<=(nr/2); i++){ g.drawLine(x, y, x+25, y-10); g.drawLine(x+50, y, x+25, y-10); y=y+50; x=x+k; g.drawLine(xx, yy, xx+25, yy-10); g.drawLine(xx+50, yy, xx+25, yy-10); xx=xx-k; yy=yy+50; } } else { for(; i<=(nr/2)+1; i++){ g.drawLine(x, y, x+25, y-10); g.drawLine(x+50, y, x+25, y-10); y=y+50; x=x+k; g.drawLine(xx, yy, xx+25, yy-10); g.drawLine(xx+50, yy, xx+25, yy-10); xx=xx-k; yy=yy+50; } } } public void actionPerformed(ActionEvent e){ nr=Integer.parseInt(tf.getText()); repaint(); } public static void main(String argumendid[]){ new Linnud(); } }