// Stores the state of the application.
export class Model {

  quarter: string;    // currently displayed quarter or undefined if none chosen
  classes: string[];  // list of chosen clases (see classes.ts for choices)

  constructor() {
    this.quarter = undefined;
    this.classes = [];
  }

  // Change the quarter to the given value, which can be undefined.
  resetQuarter(quarter: string) {
    this.quarter = quarter;
    this.classes = [];
  }

  // Returns whether this class is in the list of classes.
  hasClass(name: string) {
    return this.classes.indexOf(name) >= 0;
  }

  // Add the given class to the list of classes if not already present.
  addClass(name: string) {
    const index = this.classes.indexOf(name);
    if (index < 0)
      this.classes.push(name);  // add at the end
  }

  // Removes the given class from the list if currently present.
  removeClass(name: string) {
    const index = this.classes.indexOf(name);
    if (index >= 0)
      this.classes.splice(index, 1);  // remove that 1 element
  }
}