#ifndef STUDENT_CLASS_HEADER_INCLUDED
#define STUDENT_CLASS_HEADER_INCLUDED

#include <cstddef>

class Scores
{
    short num_grades,
          max_grades;
    double * grades;

    void fill(const double gr[]);
    void alloc(short max)
    {
        delete [] grades;
        grades = new double [max];
        max_grades = (grades != nullptr) ?  max : (num_grades = 0);
        return;
    }
public:
    Scores(void) : num_grades(0), max_grades(0), grades(nullptr) {}
    Scores(const double gr[], short cnt);
    Scores(const Scores & s);
    ~Scores(void) { delete [] grades; }

    Scores & operator=(const Scores & s);

    bool add_score(double s)
    {
        bool worked = false;
        if (num_grades != max_grades)
        {
            grades[num_grades++] = s;
            worked = true;
        }
        return worked;
    }

    double get_score(short which) const
    {
        return (which < num_grades && which >= 0) ? grades[which] : -1.0;
    }

    bool set_score(short which, double s)
    {
        bool worked = false;
        if (which < num_grades && which >= 0)
        {
            grades[which] = s;
            worked = true;
        }
        return worked;
    }

    double get_average(void) const;
    short get_count(void) const { return num_grades; }
    short get_max_count(void) const { return max_grades; }

    void reset(void) { num_grades = 0; return; }
    void reset(const double gr[], short cnt);
};

#endif
