Lab 3: Top Ten List

Objectives. The objectives of this lab are:

Part I: Implementing and Testing SLinkedList

Source

Goodrich and Tamassia, 4E, § 3.2.

Download the partially implemented definition of Node.java and SLinkedList.java. We discussed these classes during lecture.

Implement and test the following methods, which are given in stub form.

Suggestions

Part II: Implementing and Testing the TopTenList Class

Download the partially implemented TopTenList.java and complete the stub method add(Node). This method should insert a Node into the list in non-increasing order. For example, if Node contains an Integer element, then the list will be maintained in non-increasing order:

Size= 10: 875   856     804     789     785     693     693     542     531     520

The TopTenList should never exceed 10 elements. Use (and/or modify) the main() program to test your implementation.

Part III: Optional Challenge

Modify your implementation so that you can store a game score in the top-ten list.

Define a GameScore object that consists of an Integer representing the player's score, and a String representing the player's name.

This class should implement the Comparable interface, which contains one method, compareTo(Object):int. This method would be used as follows:

   obj1.compareTo(obj2)
It should return a negative number if obj2 is less than obj1. It should return 0 if obj1==obj2, and it should return a positive integer if obj2 is greater than obj1.

Challenging: . Implementing this class will require you to deal with various cast operations.

Documentation Requirements

All of the methods in your program should contain Javadoc documentation of the method's parameters and return values. This applies to all code you write in this course. Use the partial programs as examples for style and format.

You're done. Great work!