BalloonFamily.java
1    package balloonpeople;
2    
3    import painter.SPainter;
4    
5    import javax.swing.*;
6    import java.util.ArrayList;
7    import java.util.Scanner;
8    
9    public class BalloonFamily {
10       private ArrayList<BalloonPerson> balloonFam;
11   
12       public BalloonFamily(int numOfBalloonPpl) {
13           balloonFam = new ArrayList<>();
14           Scanner scanner = new Scanner(System.in);
15           for (int i = 0; i < numOfBalloonPpl; i++) {
16           String command1 = JOptionPane.showInputDialog(null, "Name?");
17           String command2 = JOptionPane.showInputDialog(null, "Age?");
18           String command3 = JOptionPane.showInputDialog(null, "Height?");
19           int y = Integer.parseInt(command2);
20           int z = Integer.parseInt(command3);
21           //String command1 = "egg";
22           //int y = 68;
23           //int z = 50;
24           BalloonPerson balloonPerson = new BalloonPerson(command1, y, z);
25           balloonFam.add(balloonPerson);
26           }
27       }
28       public void paint(SPainter miro) {
29           miro.moveToCenter();
30           //miro.mlt(900/balloonFam.size()*1.875);
31           //miro.mlt(450-(900/(balloonFam.size() + 1)));)
32           BalloonPerson middle = balloonFam.get(balloonFam.size()/2);
33           middle.paint(miro);
34           BalloonPerson right = balloonFam.get(2);
35           BalloonPerson left = balloonFam.get(0);
36           //double number = 450-(middle.getHeight()*2);
37           double number = (225+middle.getHeight());
38           //double number2 = 450+(middle.getHeight()*2);
39           double number2 = (225+middle.getHeight());
40           miro.moveToCenter();
41           miro.mrt(number);
42           right.paint(miro);
43           miro.moveToCenter();
44           miro.mlt(number2);
45           left.paint(miro);
46           //for (int i = (balloonFam.size()/2)+ 1; i < balloonFam.size(); i ++) {
47               //BalloonPerson temp = balloonFam.get(i);
48               //miro.mrt(number+middle.getHeight());
49               //temp.paint(miro);
50               //miro.moveToCenter();
51          // }
52           //for (int i = (balloonFam.size()/2)-1; i < balloonFam.size(); i--) {
53               //BalloonPerson temp = balloonFam.get(i);
54               //miro.mlt(number2+middle.getHeight());
55               //temp.paint(miro);
56               //miro.moveToCenter();
57           //}
58       }
59   
60       public String toString() {
61           for (int i = 0; i < balloonFam.size(); i++) {
62               balloonFam.get(i).toString();
63           }
64           String temp = balloonFam.toString();
65           return temp;
66       }
67   }