title: How do I add students to a roster (from different classes in Java)?
body: <p>Brevity isn't wise here, so I made some changes and laid everything out.
  I'm still at my wits' end trying to figure this out and made some changes that was recommended.</p>
  
  <p>I'm trying to invoke the method in the driver program to add objects called students, defined in the Student-class, to be added to a roster found in the Course-class so the driver program can print out who is in the course. The Course-class has a method called addStudent which returns a boolean expression. Depending if there is enough room to add the student, the student will be added. ArrayList-class is not allowed (i.e ArrayList - something or other cannot be used).</p>
  
  <p>Here's what I have:</p>
  
  <p>Below is my Student class:</p>
  
  <pre><code>public class Student {
  private String name;
  private String iD;
  private boolean tuitionPaid;
  /**Constructor*/
  public Student(String studentName, String studentID)
  {
      name = studentName;
      iD = studentID; 
  }
  /**Getters and Setters are below*/
  public String getStudentName()
  {
      return name;
  }
  public void setStudentName(String studentName)
  {
      name = studentName;
  }
  public String getStudentID()
  {
      return iD;
  }
  public void setStudentID(String studentID)
  {
      name = studentID;
  }
  /**The toString method below*/
  public String toString()
  {
      String message = name + iD;
      return message;
  }
  }
  </code></pre>
  
  <p>Below is the Course class:</p>
  
  <pre><code>public class Course {
  private String name;
  private int maxSize;
  private String[] roster;
  
  public Course(String courseName, int courseMaxSize)
  {
      name = courseName;
      maxSize = courseMaxSize;
  }
  
  
  /**Getters and Setters are below*/
  public String getCourseName()
  {
      return name;
  }
  public void setCourseName(String courseName)
  {
      name = courseName;
  }
  public int getCourseMaxSize()
  {
      return maxSize;
  }
  public void setCourseMaxSize(int courseMaxSize)
  {
      maxSize = courseMaxSize;
  }
  public String[] getCourseRoster()
  {
      return roster;
  }
  public void setCourseRoster(Student s)
  {
      String[] courseRoster = {s.toString()};//intended to pass the student name and ID
          roster = courseRoster;             //to the instance data variable
  
  }
  
  /**The toString method is below*/
  public String toString()
  {
      String message = name + " course has a class size of " + maxSize;
      return message;
  }
  
  
  /**Three requested methods are below*/
  public boolean addStudent(Student s)
  {
  
      boolean atCapacity = false;
      if(roster.length&gt;=5)
      {
          String courseRoster[] = {s.toString()};//intended to pass the formal parameter
          roster = courseRoster;                 //to store as an instance data
          atCapacity = false;
  
      }
      else
      {
          atCapacity = true;      
      }
      return atCapacity;
  }
  public boolean dropStudent(Student s)
  {
      boolean dropStudent = true;
      for( int index=0; index&lt;roster.length - 1; index++ )//Goes through the roster
      {                                                   
          if( roster[index] == s.getStudentID() )//If a student matches, they are
          {
              s.setStudentID(null);               //dropped a student from a course
              s.setStudentName(null);             //their existence should be null
              dropStudent = true;
          }
          else
          {
              dropStudent = false;
          }
      }   
      return dropStudent;
  }
  public void printRoster()
  {
  
          if(roster.length == 0)//In case there is no one in the roster
          {
              System.out.println("There is no one in this roster.");//this message prints
          }
          else
          {
          System.out.println(roster);//Everyone in class will be printed
          }
  }
  }
  </code></pre>
  
  <p>Below is the Driver Program:</p>
  
  <pre><code>public class Project2DriverProgram {
  
  public static void main(String[] args) {
  
      Student[] students = new Student[5];//Creates an array of objects from the Student-class
      students[0] = new Student("Bill", "123");//Instantiates the array at 0 with actual parameters
  
      Course newCourse = new Course("Philosophy", 5);//Creates an object and instantiates
  
  
      newCourse.getCourseRoster();
      newCourse.setCourseRoster(students[0]); //Sets the student to be in the roster
  
      newCourse.addStudent(students[0]);//Adds student to the course 
  
  
      newCourse.printRoster();//prints values of the roster
  
  }
  
  }
  </code></pre>
  
  <p>After all that, I get a hashcode, or a memory address, is printed. I would like this to be expandable so that when students[1] becomes existent, then that too can easily be added to the course roster and so on.</p>
  
  <p>(P.S First post. Here's to not giving up. :))</p>