Consider the courses taken by students. Student std1 has taken courses Java I, Java II. Now that person registers Data Structures. Then, it is realized that Java I was not taken but transferred, so Java I is removed from the list. That student plans to take Android in the future. Finally, it is known that CISC120 was taken earlier. Later, of course, Android is not yet taken so to be removed. As such, there is a series of courses added into and removed from the course list. This scenario can be handled in a "LinkedList".
Write a Java program that can list courses taken in a linked list. You should create two classes, LinkedCourse.java and LCourseDriver.java.
LinkedCourse.java should create a class Node which can be a node component in a linked list: Node contains the data about the items and the link to the next node.
LCourseDriver.java uses the properties of the class LinkedCourse. A particular scenario will be manipulated in this class. Recall the example above, LCourseDriver.java contains:
LinkedCourse s1 = new LinkedCourse();
s1.insertAtHead("Java I");
s1.insertAtTail("Java II");
s1.insertAtTail("Data Structure");
System.out.println(s1);
System.out.println(s1.removeAtHead());
System.out.println(s1);
s1.insertAtHead("CISC120");
System.out.println(s1);
s1.insertAtTail("Android");
System.out.println(s1);
System.out.println(s1.removeAtTail());
System.out.println(s1);
output should be:
Java 1 > Java 2 > Discrete Structures
Java 1
Java 2 > Discrete Structures
CISC 120 > Java 2 > Discrete Structures
CISC 120 > Java 2 > Discrete Structures > Android
Android
CISC 120 > Java 2 > Discrete Structures