Index of /home/burt/learning/Csc120.042/Workbook/linkedlist

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[TXT]LinkedListBothTest.java2004-03-26 12:17 1.5K 
[TXT]LinkedListBothTest.txt2004-03-26 12:02 413  
[TXT]LinkedListIntNode.java2004-03-26 12:13 351  
[TXT]LinkedListNode-orig.java2004-03-26 11:12 643  
[TXT]LinkedListNode.java2004-03-26 12:14 619  
[TXT]LinkedListStringNode.java2004-03-26 12:13 370  
[TXT]LinkedListTest.java2004-03-26 12:16 455  
[TXT]LinkedListTest.txt2004-03-26 11:39 290  
[TXT]README.html2004-03-26 12:05 1.8K 
[TXT]ReadIntegerAndStrings.java2004-03-26 12:15 1.3K 

Linked List, practice with Inheritance.

Linked List, practice with Inheritance.

In this example we write a linked list class, and then extend it to be a linked list of integers or a linked list of strings. The base class, LinkedListNode, contains common functionality for either LinkedListIntNode or LinkedListStringNode. They both extend LinkedListNode so they inherit the functionality of a LinkedListNode.

However each specializes the linked list to be a list of integers or of strings. LinkedListIntNode adds a data field of integer type, and LinkedListStringNode adds a data fields of String type. The basic ability to print a linked list, that is, to step through each element, following next pointers until the next pointer has value null, and at each node calling printNode, is coded in LinkedListNode. Each of LinkedListIntNode and LinkedListStringNode override the printNode method so that it correctly prints the data field, either as an integer or as a string.

The output of running LinkedListTest is in file LinkedListTest.txt. The output of running LinkedListBothTest is in file LinkedListBothTest.txt.

Note: there is a new input class, ReadIntegerAndStrings, used in LinkeListBothTest.