package no.valg.valgnatt.database.forberedvalg.geografi;

/**
 * Created by msi on 14-Mar-16.
 */
public class Parti {
    // Nøkler
    private Krets krets;
    private String partikode;
    private boolean stiller = true; // default er at partiet stiller

    // Valgfrie data - defaulter til 0
    private int fhs;
    private int vts;
    private int mnd;
    private int umnd;

    public Parti(Krets krets, String partikode, Integer fhs, Integer vts, Integer mnd, Integer umnd) {
        this(krets, partikode, fhs, vts, mnd, umnd, true);
    }

    public Parti(Krets krets, String partikode, Integer fhs, Integer vts, Integer mnd, Integer umnd, boolean stiller) {
        this.krets = krets;
        this.partikode = partikode;
        if (fhs != null) {
            this.fhs += fhs;
        }
        if (vts != null) {
            this.vts += vts;
        }
        if (mnd != null) {
            this.mnd += mnd;
        }
        if (umnd != null) {
            this.umnd += umnd;
        }
        this.stiller = stiller;
    }

    public Krets getKrets() {
        return krets;
    }

    public String getPartikode() {
        return partikode;
    }

    public boolean isStiller() {
        return stiller;
    }

    public void leggTilStemmer(Integer fhs, Integer vts) {
        if (fhs != null) {
            this.fhs += fhs;
        }
        if (vts != null) {
            this.vts += vts;
        }
    }

    public void leggTilMandater(Integer mnd, Integer umnd) {
        if (mnd != null) {
            this.mnd += mnd;
        }
        if (umnd != null) {
            this.umnd += umnd;
        }
    }

    public int getFhs() {
        return fhs;
    }

    public int getVts() {
        return vts;
    }

    public int getMnd() {
        return mnd;
    }

    public int getUmnd() {
        return umnd;
    }

    public String toString() {
        return partikode + ": " + fhs + " + " + vts + " = " + (fhs + vts) + " stemmer, " + mnd + " mandater, " + umnd + " utjevningmandater (krets: " + krets + ")";
    }
}
