//Autosőit Liiguta kriipsu ekraanil nooleklahvidega - 3p// import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class Eksam1 extends Applet implements KeyListener{ int x=100, y=100; public Eksam1(){ addKeyListener(this); } public void paint(Graphics g){ g.drawLine(x, y, x, y+20); } public void keyPressed(KeyEvent e){ int kood=e.getKeyCode(); if(kood==KeyEvent.VK_LEFT)x--; if(kood==KeyEvent.VK_RIGHT)x++; if(kood==KeyEvent.VK_UP)y--; if(kood==KeyEvent.VK_DOWN)y++; repaint(); } public void keyReleased(KeyEvent e){} public void keyTyped(KeyEvent e){} public static void main(String argumendid[]){ Frame f=new Frame("Eksamiülesanne nr 1 - Madli Tuisk"); f.add(new Eksam1()); f.setSize(300, 300); f.setVisible(true); } }