//**************************************************************** // TRABAJO ISBC : INTEGRACION JAVA-JESS. CASO DEL ELEVADOR //**************************************************************** // // Fichero: CanvasPasajero.java // Autor: // Modificado por: Daniel Urieta Lopez // Proposito: Contiene la clase CanvasPasajero que representa // textualmente los pasajeros de un vector de // pasajeros. // //**************************************************************** import java.awt.*; import java.util.*; public class CanvasPasajero2 extends Canvas { int numPasajeros; public CanvasPasajero2() { numPasajeros = 0; setSize(70,60); setBackground(Color.white); } public void addPasajero() { numPasajeros++; this.validate(); this.repaint(); } public void removePasajero() { numPasajeros--; this.validate(); this.repaint(); } public void paint(Graphics g) { g.setColor(Color.white); g.fillRect(0, 0, this.getWidth(), this.getHeight()); //le dibujo el fondo g.setColor(Color.black); g.drawRect(0, 0, this.getWidth(), this.getHeight()); //le dibujo el marco int x = 0; for (int j = 0; j < numPasajeros; j++) { g.drawOval(x+3, 10, 4, 4); // cabeza g.drawLine(x, 20, x+10, 20); // brazos g.drawLine(x+5, 15, x+5, 25); // tronco g.drawLine(x+5, 25, x+2, 30); // pierna izda g.drawLine(x+5, 25, x+8, 30); // pierna dcha x = x + 14; } } }