1 package balloonpeople; 2 3 import painter.SPainter; 4 import shapes.SCircle; 5 6 import java.awt.*; 7 import java.util.Random; 8 9 public class BalloonPerson { 10 private String name; 11 private int age; 12 private int height; 13 private Color color; 14 15 public BalloonPerson(String name, int age, int height) { 16 this.name = name; 17 this.age = age; 18 this.height = height; 19 Random rgen = new Random(); 20 color = new Color(rgen.nextInt(255), rgen.nextInt(255), rgen.nextInt(255)); 21 } 22 23 public String toString() { 24 return name + ", age: " + age + " years old, height in inches: " + height; 25 } 26 27 public void paint(SPainter miro) { 28 SCircle balloon = new SCircle(height * 2); 29 SCircle face = new SCircle(height); 30 miro.setColor(color); 31 miro.paint(balloon); 32 33 //this is the mouth part 34 miro.mbk(balloon.radius()*0.6); 35 face.shrink(height/2); 36 miro.setColor(color.BLACK); 37 miro.paint(face); 38 miro.mfd(balloon.radius()*0.6); 39 40 //white parts of eyes 41 42 face.expand(height/2); 43 miro.mlt(balloon.radius()/2.5); 44 miro.mfd(balloon.radius()/6); 45 miro.setColor(color.WHITE); 46 miro.paint(face); //right eye 47 miro.mrt(balloon.radius()/1.25); 48 miro.paint(face); //left eye 49 miro.mlt(balloon.radius()/1.25); 50 miro.mbk(balloon.radius()/6); 51 52 //black parts of eyes 53 miro.setColor(color.BLACK); 54 face.shrink(height/2); 55 miro.mfd(balloon.radius()/6); 56 miro.paint(face); 57 miro.mrt(balloon.radius()/1.25); 58 miro.paint(face); 59 miro.mbk(balloon.radius()/6); 60 miro.mlt(balloon.radius()/1.25); 61 } 62 63 public int getHeight() { 64 return height; 65 } 66 } 67