Description
Objectives
• Practice with interfaces and abstract data types
• Introduction to linked data structures
Exercise – Interfaces
In this lab you will be implementing and testing the StudentNode and StudentLinkedList classes depicted
in the following UML diagram.
Recall: the dashed arrow implies that one class implements the interface pointed to, the solid line means
one class uses the other class.
1. Download StudentList.java Lab4Tester.java and Student.java to your Lab4 folder.
2. Implement the StudentNode class in a new file called StudentNode.java in your Lab4 folder.
a. Write and test each constructor and method one at a time.
b. To test, compile and run Lab4Tester.java
StudentList
<>
+ add(Student): void
+ size(): int
+ toString(): String
+ removeFront(): void
+ contains(): boolean
StudentLinkedList
– head: StudentNode
– count: int
+ StudentLinkedList()
+ add(Student): void
+ size(): int
+ toString(): String
+ removeFront(): void
+ contains(Student): boolean
StudentNode
+ next: StudentNode
– data: Student
+ StudentNode (Student)
+ StudentNode (Student, StudentNode)
+ getNext(): StudentNode
+ setNext(StudentNode): void
+ getData(): Student
+ setData(Student): void
Student
– sID: String
– grade: int
+ Student()
+ Student (String, int)
+ getSID(): int
+ setSID(String): void
+ getGrade(): int
+ setGrade(int): void
+ toString(): String
+ equals(Student): boolean
CHECKPOINT (Ungraded) – Now might be a good time to check-in with the TA if you are aren’t
comfortable in your understanding of how the StudentNode should be implemented. You will need to use
this class as part of your linked list in the next part, so please don’t hesitate to ask questions if you are
unclear about anything.
3. Implement the StudentLinkedList class in a new file called StudentLinkedList.java in your Lab4
folder
a. This class MUST implement the StudentList interface:
public class StudentLinkedList implements StudentList {…
b. Write and test each constructor and method one at a time.
You will need to write tests in the testList method in Lab4Tester.java
If you are unsure how to test, look at the testNode method for help and the testShapeList
method in Lab3Tester.java from last week.
SUBMISSION (Graded) – Submit the StudentLinkedList.java and StudentNode.java files into the Lab 4
submission page on ConneX.




