title: Array of Student objects java
body: <p>Just to give a run down of what I am trying to do, here is the HW my professor gave me:</p>
  
  <ol>
  <li>Define a class Student which extends Person. It adds the attributes </li>
  </ol>
  
  <p>Int Test1, test2, test3
  Double average
  String grade</p>
  
  <p>It has methods computeaverage() and calculategrade(). The grades are based on the average, with above 90 an A, 80 to 90 a B, 70 to 80 a C etc. All other attributes have a set and a get.</p>
  
  <ol>
  <li>Write an application that uses an array of type student of size 20. The program prompts the user for how many students are in the class and then allows them to enter the students and their test scores, then calculates their grades and prints out the list of students and their grades.</li>
  </ol>
  
  <p>That being said...</p>
  
  <p>On Thursday I saw a classmates code that he got from the teacher and he had something that I haven't seen before in my student class on line 37 (Student Constructor). Instead of having getters and setters he had code similar to what I have at line 37. But I have no idea what he did and the correct coding. So I was hoping someone here could tell me what I am doing wrong and how this code can get away without using getter and setter methods???</p>
  
  <pre><code>public class Person {
  
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) 
      {
  
  
  
          Scanner kbd = new Scanner(System.in);
          Student newStudent = new Student();
          int size;
  
          System.out.println("Enter the amount of students:");
          size = kbd.nextInt();
          Student[] myStudent = new Student[size];
          String firstName;
          String lastName;
          int test1, test2, test3;
          Student s;
  
          for (int i=0; i &lt; size; i++)
          {
  
          System.out.println("Enter first name of student: " + i);
          firstName = kbd.next();
  
          System.out.println("Enter last name if student: " +i);
          lastName = kbd.next();
  
          System.out.println("Please Enter first test score: ");
  //        JOptionPane.showInputDialog("Please enter first test score:");
          test1= kbd.nextInt();
  
          System.out.println("Please enter second test score");
  //        JOptionPane.showInputDialog("Please enter second test score:");
          test2= kbd.nextInt();
  
          System.out.println("Please enter third test score");
  //        JOptionPane.showInputDialog("Please enter third test score:");
          test3=kbd.nextInt();
  
  //        s = new Student (test1, test2, test3, firstName, lastName);
          myStudent[i].setTest1(test1);
          myStudent[i].setTest2(test2);
          myStudent[i].setTest3(test3);
          myStudent[i].setfName(fName);
          myStudent[i].setlName(lname);
  
  
          }
          for (int i = 0; i &lt; size; i++)
          {
              System.out.println(myStudent[i].getGrade());
          }
  
  
  
      }
  }
  
  
  public class Student extends Person{
  
      int test1, test2, test3;
      double average;
      String grade, firstName, lastName;
  
  
      public Student() 
      {
          test1 = 0;
          test2 = 0;
          test3 = 0;
          average = 0;
  
  
      }
  
  
  
  
      public Student(int test1, int test2, int test3, String firstName, String lastName) 
      {
          this.test1 = test1;
          this.test2 = test2;
          this.test3 = test3;
  
          this.setfirstName = firstName;
      }
  
  
      public double computeAverage()
      {
          average = (test1 + test2 + test3)/3;
          return average;
  
      }
  
      public String calculateGrade()
      {
          average = computeAverage();
  
          if (average &lt; 60){
              grade = "F";}
          else if (average &lt; 70){
              grade = "D";}
          else if (average &lt; 80){
              grade = "C";}
          else if (average &lt; 90){
              grade = "B";}
          else {
              grade = "A";
          }
          return grade;
      }
  
      public int getTest1() {
          return test1;
      }
  
      public void setTest1(int test1) {
          this.test1 = test1;
      }
  
      public int getTest2() {
          return test2;
      }
  
      public void setTest2(int test2) {
          this.test2 = test2;
      }
  
      public int getTest3() {
          return test3;
      }
  
      public void setTest3(int test3) {
          this.test3 = test3;
      }
  
      public double getAverage() {
          return average;
      }
  
      public void setAverage(double average) {
          this.average = average;
      }
  
      public String getGrade() {
          return grade;
      }
  
      public void setGrade(String grade) {
          this.grade = grade;
      }
  
  
  
  }
  </code></pre>