SnowFamily.java
package snowpeople;

import painter.SPainter;
import shapes.SCircle;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;

public class SnowFamily {
    //1. Your class should have a single instance variable – an ArrayList of snow people.
    private ArrayList<SnowPerson> SnowFamily;

    //2. Your constructor will take one argument, the number of people in the snow family.
    //The goal of your constructor will be to initialize the ArrayList instance variable as a new empty list, and to populate it with snow people according to user input.
    //3. Use the techniques we’ve used before this semester to create popup windows to ask the user for the information required to make the snow people, and add them to the ArrayList.
    //Be sure you make as many as specified by the argument to the constructor!
    public SnowFamily (int number){
        this.SnowFamily = new ArrayList<>(number);
        for ( int i = 0; i < number; i = i + 1){
            String name = getString("name of snow family" + (i + 1));
            int height = getNumber("height " + (i + 1));
            int numberOfButtons = getNumber("numberOfButtons" + (i + 1));
            SnowFamily.add(new SnowPerson(name, height, numberOfButtons));
        }
    }

    //4. Add a toString method which returns a string containing the details of each snow person in the family. You should make use of the SnowPerson's toString method.
    @Override
    public String toString() {
        StringBuilder returnString = new StringBuilder();
        for (int i = 0; i < SnowFamily.size(); i++) {
            returnString.append(SnowFamily.get(i));
        }
        return returnString.toString();
    }
    public void paint(SPainter painter) {
        int paddingX = 100;
        int startingX = 200;
        int startingY = 200;
        painter.moveTo(new Point2D.Double(startingX, startingY));
        for (int i = 0; i < SnowFamily.size(); i++) {
            SnowFamily.get(i).paint(painter);
            painter.moveTo(new Point2D.Double(SnowFamily.get(i).height() + paddingX, SnowFamily.get(i).height()));
        }
    }
    private static int getNumber(String prompt) {
        String nss = JOptionPane.showInputDialog(null,prompt+"?");
        Scanner scanner = new Scanner(nss);
        return scanner.nextInt();
    }

    private String getString(String prompt) {
          String nss = JOptionPane.showInputDialog(null, prompt + "?");
         Scanner scanner = new Scanner(nss);
        return scanner.next();
    }
    private static Color randomColor() {
        Random rgen = new Random();
        int r = rgen.nextInt(256);
        int g = rgen.nextInt(256);
        int b = rgen.nextInt(256);
        return new Color(r,g,b);
    }
}