So I have this class called memoryStructure which is supposed to represent support structure for object called Student which has firstName, lastName, age and university.
This is trouble part:
public class MemoryStructure {
private Student[] memoryArray;
private int currentSize;
private int arraySize;
// constructor goes here
/**
* Adds the object <code>student</code> to the collection right after the
* last element in the current collection.
*
* @param student
* Object to be added to the collection.
*/
public void add(Student student) {
// to be done
Can someone at least go a bit through explaining what should I write here? It's my first touch with Java and I am having a bit of trouble.
Also, should student just be made as another class with his constructor and setters/getters for changing it through memoryarray in above class?
I am also supposed to make new array once currentarray size gets bigger than arraySize, it should be 2*arraySize and have all elements from previous array copied in. Is this also put in constructor?
I hope this question isn't too broad.
List<Student> students = new ArrayList<Student>();