1 package balloonpeople; 2 3 4 import painter.SPainter; 5 6 import javax.swing.*; 7 import java.util.ArrayList; 8 9 public class BalloonFamily { 10 private ArrayList<BalloonPerson> balloonFamily; 11 public BalloonFamily(int numberOfPeople){ 12 balloonFamily = new ArrayList<>(numberOfPeople); 13 int i = 0; 14 while (i < numberOfPeople) { 15 String name = JOptionPane.showInputDialog(null, "Name of " + i + "?"); 16 String age = JOptionPane.showInputDialog(null, "Age of " + i + "?"); 17 String height = JOptionPane.showInputDialog(null, "Height of " + i + "?"); 18 BalloonPerson a = new BalloonPerson(name,Integer.parseInt(age),Double.parseDouble(height)); 19 balloonFamily.add(a); 20 i++; 21 } 22 } 23 public String toString() { 24 String output = ""; 25 for (int i = 0; i < balloonFamily.size(); i++) { 26 output+= balloonFamily.get(i).toString(); 27 } 28 return output; 29 } 30 public SPainter paint(SPainter oop) { 31 SPainter dodo = oop; 32 dodo.moveToCenter(); 33 int x = 1; 34 dodo.mrt((dodo.painterWidth/2.0)-90); 35 for (int i = 0; i < balloonFamily.size(); i++) { 36 balloonFamily.get(i).paint(dodo); 37 dodo.mrt((dodo.painterWidth/2.0)-90); 38 dodo.mlt(180*x); 39 x = x + 1; 40 } 41 return dodo; 42 } 43 44 } 45 46