Student Object (OOP Java)

Student Class

A school district decided to write a program to help keep track of various parts of the school.

It has been decided to store relevant information about Students in a Student class. Each Student will have an array of Strings to store the names of his or her teachers.

private instance variables

 

Part 1

* Construct the Java statement to declare the array called

teachersNames to store the String names of the student’s teachers

Part 2

  • write a default constructor
  • construct a method called  addTeacher( String name) that adds String name to the  teachersNames  array
    • to do this let’s create a private method  private String[] addStr( String[] input, String val) that adds value to the end of the array and returns it. [redact]Solution[/redact]
  • construct hasTeacher(String name)  that returns true if name is in the teachersName array
  • construct a method removeTeacher(String name) that removes the   String name from the  teachersNames  array.
  • construct a method the line of code needed in the setGpa(double to) method of the Student Class.
  • construct a method boolean setTeacher (String name, int index) .   This method should return true if index is valid in the array and false if  index >= teachersName.length

 

Next: The runner class