import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class korrus extends Applet implements ActionListener{ TextField tf=new TextField("3"); public korrus(){ add(tf); tf.addActionListener(this);//textboxi värk } public void paint(Graphics g){ int arv=Integer.parseInt(tf.getText().trim()); int nr=1; int a=80;//ühe korruse kõrgus /* g.drawLine(150,50,40,100);//vasak katus g.drawLine(150,50,260,100);//parem katus */ int xd[]=new int[3];// kolmnurga joonistamine xd[0]=30; //katus xd[1]=150; xd[2]=270; int yd[]=new int[3]; yd[0]=100; yd[1]=50; yd[2]=100; g.fillPolygon(xd, yd, 3); g.drawRect(80,50,30,30); //korsten g.drawRect(80,50,15,7); g.drawRect(95,50,15,7); g.drawRect(80,57,7,7); g.drawRect(87,57,15,7); g.drawRect(102,57,8,7); g.drawRect(80,64,15,7); g.drawRect(95,64,15,7); g.drawRect(40,100+arv*80,220,80); //keldrikorrus g.setColor(Color.gray); //värvin ukse halliks g.fillRect(130,120+arv*80,40,60);//uks g.setColor(Color.white); //ukselink valgeks g.drawLine(135,150+arv*80,145,150+arv*80); //g.drawRect(130,120+arv*60,40,60); while(nr<=arv){ g.setColor(Color.black); g.drawRect(40,20+a,220,80); //x,y,laius, kõrgus //korrus g.drawRect(80,40+a,40,30); //aken vasak g.drawLine(100,40+a,100,70+a);//vasaku akna kriips g.drawRect(180,40+a,40,30); //aken parem g.drawLine(200,40+a,200,70+a);//parema akna kriips nr=nr+1; a=a+80; } } public void actionPerformed(ActionEvent e){ repaint(); } }