I am practicing with LinkedList in java. I have bought a book where one of the exercises is to create a student directory using a singly linkedlist. The directory can store the students full name and gpa.
I need to implement and write the code for the methods removeFirst, removeLast, insertFirst, insertLast, getStudent etc(which are usually built in iterators of the linkedlist). I don't know where to create these custom iterators. The goal is to be able to make a linkedlist of type StudentDirectory in my main and be able to use my custom methods to remove, add, get, and generate list of students in the linked list. This leads me to believe that all of these methods need to live in my StudentDirectory class but unfortunately I do not know how to begin.
I have posted my code but I would appreciate a nudge in the right direction. I dont want any total solutions for I want to be able to do this on my own rather than copying someone else's code. I understand I need to iterate through the linkedlist via traversing through the nodes in the linkedlist but I dont know how/where to declare the nodes head
public class studentDirectory {
private String fullName;
private double gpa;
public studentDirectory(String name, double gpa){
fullName = name;
this.gpa = gpa;
}
public void setGpa(double grade){
gpa = grade;
}
public void setName(String name){
fullName = name;
}
public double getGpa(){
return gpa;
}
public String getName(){
return fullName;
}
public void insertAtEnd(studentDirectory lastItem){
}
public void insertAtStart(studentDirectory firstItem){
}
public void getStudent(studentDirectory student){
}
public void updateGpa(studentDirectory update){
}
public void removeFirst(studentDirectory first){
}
public void removeLast(studentDirectory last){
}
public void generateStudentList(){
}
Node<T>, it might have aT(orOptional<T>)valueand aNode<T>(orOptional<Node<T>>)next. But that's literally the minimum you need for a "LinkedList".