title: Student Database with linked lists
body: <p>I am still a pretty novice programmer so please be as descriptive as possible. I'm having issues getting all my code working for my assignment. The assignment gives me four complete files that do not need changed(StudentIf.java StudentCollectionIf.java StudentLLNode.java and StudentRecords.java) and a test text file with a list of names an ID and five grades.</p>
  
  <p>Link to Assignment Instructions:
  <a href="https://www.cs.colostate.edu/~cs161/Fall14/more_assignments/P5/P5.html" rel="nofollow">https://www.cs.colostate.edu/~cs161/Fall14/more_assignments/P5/P5.html</a></p>
  
  <p>The two files that I have modified are Student.java and StudentLL.java
  Also in my Run Configuration-Arguments I have "cs161 5"
  I know its a lot but any help would be fantastic.</p>
  
  <p>I am currently getting this output:(Top Score and Avg Score are not implemented yet)</p>
  
  <pre><code>Course cs161: 5 grades
  Top Score: 10.0
  Avg Score: 10.0
  Course: null
  null    0   score: 81.00
  </code></pre>
  
  <p>What should be produced</p>
  
  <pre><code>Course cs161: 5 grades
  Top Score: 90.0
  Ave Score: 76.16
  Course: cs161
  Jim     1234  50 40 50 60 70    score: 54.00
  John    1243  60 70 80 55 55    score: 64.00
  Mick    1324  70 60 70 80 90    score: 74.00
  Mike    1342  60 70 80 90 99    score: 79.80
  Lena    1423  99 50 90 90 85    score: 82.80
  Leila   1432  60 70 60 70 60    score: 64.00
  Ada     2134  90 90 90 90 90    score: 90.00
  Adam    2143  85 95 85 75 65    score: 81.00
  Helen   2314  89 79 99 89 88    score: 88.80
  Ellen   2341  90 95 88 77 66    score: 83.20
  </code></pre>
  
  <p>My code for Student.java and StudentLL.java</p>
  
  <pre><code>import java.text.DecimalFormat;
  import java.util.Arrays;
  
  public class Student implements StudentIF{
  
  
  
      private String name;
      private int id;
      private int[] grades;
      private int numGrades;
      private int totalGrades;
  
      // The constructor
      //    initializes the instance variables  
      //    name, id, grades = new int[totalGrades], and numGrades = 0;
      public Student (String name, int id, int totalGrades){
          name = this.getName();
          id = this.getId();
          grades = new int[totalGrades];
          numGrades= 0;
  
         //System.out.println(name+"  "+id+"   "+grades[0]+" "+grades[1]+" "+grades[2]+" "+grades[3]+" "+grades[4]+" "+"   "+totalGrades);
      }
  
      public String toString() {
          String res = name + "\t" + id + " ";
          for (int i=0; i &lt; totalGrades; i++) {
              res += " " + grades[i];
          }
          res += "\tscore: " + new DecimalFormat("0.00").format(computeScore());
          return res;
      }
  
      @Override
      public int compareTo(StudentIF arg0) {
          if (arg0 == null) {
              return 1;
          }
          if (this.id &gt; arg0.getId())
              return 1;
          else if (this.id &lt; arg0.getId())
              return -1;
          else
              return 0;
      }
  
      @Override
      public String getName() {
          return name;
      }
  
      @Override
      public int getId() {
          return id;
      }
  
      @Override
      public double computeScore() {
          double total = 0;
            if (numGrades == 0) {
              return total;
            }
            if (numGrades &gt; grades.length) {
              numGrades = grades.length;
            }
            for (int i = 0; i &lt; numGrades; i++) {
              total += grades[i];
            }
            return total / numGrades;
          //return 0;
      }
  
      @Override
      public boolean addGrade(int newGrade) {
          if(numGrades&lt;grades.length){
              grades[numGrades] = newGrade;
              numGrades++;
             // System.out.println(grades[0]+" "+grades[1]+" "+grades[2]+" "+grades[3]+" "+grades[4]);
              return true;
          }
          return false;
      }
  
  
      @Override
      public boolean equals(StudentIF other) {
          if (other.getId() == this.getId()) {
              return true;
            }
            return false;
      }
  
  }
  </code></pre>
  
  <p>========</p>
  
  <pre><code>public class StudentLL implements StudentCollectionIF{
      private String course;
      private StudentLLNode head;
      private int size;
      private boolean debug;  // you can set debug in main
  
      // the client code provides the course name
      public StudentLL(String course){
          course = this.course;
      }
  
      public String toString(){
          String res = "Course: " + course + "\n";
          for(StudentLLNode curr = head; curr !=null; curr=curr.getNext()){
               StudentIF nS = curr.getStd();
               res = res + nS + "\n";
          }
          return res;
      }
  
      @Override
      public boolean insort(StudentIF s) {
          StudentLLNode curr = head;
  
          if (s == null) {
              return false;
          }
          if (head == null) {
              StudentLLNode student = new StudentLLNode(s);
              head = student;
              size++;
              //System.out.println("working");
              return true;
          } else {
              if (curr.getStd().compareTo(s) == 0) {
                  //System.out.println("working");
                  return false;
              }
              while (curr.getNext() != null) {
                  if(s.compareTo(curr.getStd()) == 1){
                      //c
                  }
                  curr = curr.getNext();
              }
              //c
              StudentLLNode student1 = new StudentLLNode(s);
              curr.setNext(student1);
              size++;
              return true;
          }
      }
  
      @Override
      public boolean remove(StudentIF s) {
          StudentLLNode current = head;
          if(s == null){
              return false;
          }
          if(s.getId() == (head.getStd().getId())){
              //StudentLLNode  top = head;
              head = head.getNext();
              size--;
              return true;
          }
          else{
              StudentLLNode previous, next;
              previous = current;
              current = current.getNext();
              while(current != null){
                 next = current.getNext();
                 if(s.getId() == (current.getStd().getId())){  
                      previous.setNext(next); //doesn't matter if next is null or not
                      size--;
                      return true;
                  }
                 previous = current;
                 current = next;
              }
          }
          return false;
        }
  
      @Override
      public int size() {
          // TODO Auto-generated method stub
          return size;
      }
  
      @Override
      public double classAvg() {
          //double total = 0.0;
          //for (int i=0; i&lt;this.size(); i++) {
          //  total += grades[i];
          //}
          //return total / grades.length;
          return 10;
      }
  
      @Override
      public double classTopScore() {
  
          return 10;
      }
  }
  </code></pre>