/*
 * Copyright (c) 2004-2017, by Alex Leigh.
 * All rights reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */

package lc.mecha.util;

import java.util.List;

public class ListCalculator {
    private final int cnt;
    private int avg = 0;
    private int min = 0;
    private int max = 0;
    private int sum = 0;

    public ListCalculator(final List<Integer> marks) {

        for (final Integer x : marks) {
            sum += x;
            min = Math.min(x, min);
            max = Math.max(x, max);
        }
        cnt = marks.size();
        if (cnt != 0)
            avg = sum / cnt;
    }


    public int getAvg() {
        return avg;
    }

    public int getMin() {
        return min;
    }

    public int getMax() {
        return max;
    }

    public int getSum() {
        return sum;
    }

    public int getCnt() {
        return cnt;
    }

    @Override
    public String toString() {
        return "ListCalculator{" +
                "avg=" + avg +
                ", min=" + min +
                ", max=" + max +
                ", sum=" + sum +
                ", cnt=" + cnt +
                "} " + super.toString();
    }
}
