This question has been answered
Question

Please assist with my code below. I dont know what I am doing wrong. I am trying to produce the below The

StudentList class should have:

1) Three instance variables: an array of Students, the maximum size of the array (an int) and the current number of students in the array (an int)

2)  A constructor that takes one parameter: the maximum size of the array. The other instance variables must be initialized in the constructor (assume that the StudentList will be empty when constructed).

3)  A method contains(Student) that checks if the student is already in the list and returns a boolean (true if in the list or false otherwise).

4) A method addStudent that has a parameter of type Student, adds the Student to the list only if there is enough space. This method returns a boolean (true if the student was added and false otherwise).

·        A toString method which returns a String containing all the Students in the list, one Student per line (as shown below).

--------------------------------------------------------------------------------My code currently---------------------------

public class StudentList

{

  

 private String [] students;

 private int currentNum;

 private static final int MAX_SIZE = 1000;

 

 

 public StudentList()

 {

 

  students = new Student[MAX_SIZE];

  currentNum = 0;

 }

  

 

 public boolean contains(Student s)

 {

  if (student.contains(student)){

  return true;

  }

  else{

  return false;

  }

 }

  

 public boolean addStudent(Student s)

 {

  for (int i = 0; i < currentNum; i++)

 }

  return true; 

  else

  return false;

  

  

 }

 

  

 public String toString()

 {

  String list = "";

  for (int i = 0; i < currentNum ; i++);

  {

   list += students[i];

  }

  return list;

 }

  

}

Answered by Expert Tutors
Step-by-step explanation
I dont know what I am doing wrong. I am trying to produce the below The StudentList class should have: 1) Three instance variables: an array of...
Get unstuck

378,310 students got unstuck by Course
Hero in the last week

step by step solutions

Our Expert Tutors provide step by step solutions to help you excel in your courses