/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package FanManager.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;

public class FanGroup implements Serializable {

    /**
     * For serialization/deserialization to check class version.
     */
    private static final long serialVersionUID = 8674918854563762484L;

    private ArrayList<Fan> fans;

    private double temperature;
    private double humidity;
    private double barometricPressure;

    // Constructor
    //
    public FanGroup(double temperature, double humidity, double barometricPressure) {
        super();
        this.fans = new ArrayList<Fan>();
    }

    public FanGroup(ArrayList<Fan> fans, double temperature, double humidity, double barometricPressure) {
        super();
        this.fans = fans;
        this.temperature = temperature;
        this.humidity = humidity;
        this.barometricPressure = barometricPressure;
    }

    // Takes array of fans
    public FanGroup(Fan[] fans, double temperature, double humidity, double barometricPressure) {
        super();
        this.fans = new ArrayList<Fan>(Arrays.asList(fans));
        this.temperature = temperature;
        this.humidity = humidity;
        this.barometricPressure = barometricPressure;
    }

    public void update(FanGroup fg) {
        this.fans =  fg.fans;
        this.temperature = fg.temperature;
        this.humidity = fg.humidity;
        this.barometricPressure = fg.barometricPressure;
    }
    
    // Getters & Setters
    //
    // Fans
    public ArrayList<Fan> getFans() {
        return fans;
    }

    public synchronized void setFans(ArrayList<Fan> fans) {
        this.fans = fans;
    }

    // Takes array of fans
    public synchronized void setFans(Fan[] fans) {
        this.fans = new ArrayList<Fan>(Arrays.asList(fans));
    }

    // Temperature
    public double getTemperature() {
        return temperature;
    }

    public void setTemperature(double temperature) {
        this.temperature = temperature;
    }

    // Humidity
    public double getHumidity() {
        return humidity;
    }

    public void setHumidity(double humidity) {
        this.humidity = humidity;
    }

    // Barometric Pressure
    public double getBarometricPressure() {
        return barometricPressure;
    }

    public void setBarometricPressure(double barometricPressure) {
        this.barometricPressure = barometricPressure;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof FanGroup) {
            FanGroup temp = (FanGroup) obj;
            if (this.temperature == temp.temperature
                    && this.humidity == temp.humidity
                    && this.barometricPressure == temp.barometricPressure
                    && this.fans.equals(temp.fans)) {
                return true;
            }
        }

        return false;
    }

}

@@ -1532,17 +1532,16 @@
 s.fans =
- 
  fg.fans
@@ -1690,20 +1690,16 @@
 %0A    %7D%0D%0A
-    
 %0D%0A    //
@@ -3156,11 +3156,961 @@
    %7D%0D%0A%0D%0A
+    public String getManagerString() %7B%0D%0A        String result = %22Manager;%22;%0D%0A%0D%0A        for (int i = 0; i %3C fans.size(); i++) %7B%0D%0A            result = result%0D%0A                    + String.format(%22f%25d%5B%25d,%25.2f%5D;%22, (i + 1),%0D%0A                            fans.get(i).getSpeed(),%0D%0A                            fans.get(i).getDuty());%0D%0A        %7D%0D%0A%0D%0A        result = result + %22end%5Cn%22;%0D%0A%0D%0A        return result;%0D%0A    %7D%0D%0A%0D%0A    public String getPrototypeString() %7B%0D%0A        String result = %22Proto;%22%0D%0A                + String.format(%22t%5B%25.1f%5D;h%5B%25.1f%5D;p%5B%25.2f%5D;%22,%0D%0A                        temperature,%0D%0A                        humidity,%0D%0A                        barometricPressure);%0D%0A%0D%0A        for (int i = 0; i %3C fans.size(); i++) %7B%0D%0A            result = result%0D%0A                    + String.format(%22f%25d%5B%25.1f%5D;%22, (i + 1),%0D%0A                            fans.get(i).getTemperature());%0D%0A        %7D%0D%0A%0D%0A        result = result + %22end%5Cn%22;%0D%0A%0D%0A        return result;%0D%0A    %7D%0D%0A%0D%0A
 %7D%0D%0A

Add FanGroup methods that convert state to Strings for fan prototype communication;