//******************************************************************** // StickFigure.java Author: Lewis and Loftus // // Classe per rappresentare una figurina stilizzata. //******************************************************************** import java.awt.*; public class StickFigure { private int baseX; // centro della figura private int baseY; // pavimento private Color color; // colore private int height; // altezza //----------------------------------------------------------------- // Costrutore, inizializza gli attributi della figura. //----------------------------------------------------------------- public StickFigure (int center, int bottom, Color shade, int size) { baseX = center; baseY = bottom; color = shade; height = size; } //----------------------------------------------------------------- // Disegna la figura corrente relativamente a baseX, baseY e height. //----------------------------------------------------------------- public void draw (Graphics foglio) { int top = baseY - height; // cima della testa foglio.setColor (color); foglio.drawOval (baseX-10, top, 20, 20); // testa foglio.drawLine (baseX, top+20, baseX, baseY-30); // corpo foglio.drawLine (baseX, baseY-30, baseX-15, baseY); // gambe foglio.drawLine (baseX, baseY-30, baseX+15, baseY); foglio.drawLine (baseX, baseY-70, baseX-25, baseY-70); // braccia foglio.drawLine (baseX, baseY-70, baseX+20, baseY-85); } }