/* Student.java       Solution to lab 10 exercise

 A Student has a name and a test score
*/

public class Student {
   private String name;  // The name of the student
   private int testscore;  // The test score

   // Constructor
   /* This Student has name s */
   public Student(String _name) {
      setName(_name);
   }

   // Access methods, i.e. getters and setters
   // Returns the student's name
   public String getName() {
       return name;
   }

   // Sets the student's name to newName
   public void setName(String newName) {
       name = newName;
   }

   // Returns the student's test score (the testscore field)
   public int getTestscore() {
       return testscore;
   }

   // Sets the student's testscore to score, if it is in [0, 100], 0 otherwise
   public void setTestscore(int score) {
       if(score >=0 && score <= 100)
           testscore = score;
       else
           testscore = 0;
   }

   // The toString method
   public String toString() {
       return "Name: " + name + ", Test score: " + testscore;
   }
}

