/*Student problem from the quiz*/

public class Student1 {
  
  //instance fields 
  private int numQuizzes;
  private int totalScore;
  private String name;

  //constructors
  public Student1(String name) {

    //make sure you understand the "this" and why it's needed
    totalScore = 0;
    this.name = name;
    numQuizzes = 0;

  }
  public Student1(String name, int quizzes, int totalScore) {

    //make sure you understand the "this" and why it's needed
    this.totalScore = totalScore; 
    this.name = name;
    numQuizzes = quizzes;
  }

  //make sure you know whether using Student s = new Student() would work//

  //methods
  public String getName() {
    return name;
  }

  public int getTotalScore() {
    return totalScore;
  }

  public void addQuiz(int score) {
    totalScore += score; //recall: same as "totalScore = totalScore + score;"
    ++numQuizzes;        //make sure you understand "++"
  }
  
  public double getAverageScore() {

    // make sure you understand:
    //	1.  why the return type is "double"
    //	2.  why the casting is needed in the statement below

    double result = (double)totalScore/numQuizzes;
    return result;
  }
}
