CSC220 Lab Number 3
Due: 10:59AM, Tuesday, September 21

This lab consists of three parts.

Part 1

Download the following file:

The task is to implement missing methods in KWLinkedList.java. They are:

Part 2

Download the following files:

The Router class object consists of three data fields:

Necessary operations for creating and accessing a Router class object are defined in this java file. Suppose we are maintaining a KWLinkedList of Router class objects, no two names are identical. A data of the list can be read from a file that has in each line has a Router class object description, where the three data fields are written in plain text with a common as a separator, such as "Mitsu:10.0:9.0". router-data.txt is a sample fle. Your task is to write a class named, RouterList.java, whose data field is a KWLinkedList of Router class objects, and has a method that reads data from such a file, where the file is specified using JFileChooser.

Part 3

Write a method for the class RouterList.java code that takes as input two String objects, NAME1 and NAME2, and compute, if both String objects appear as names of Router class objects on the list, a double value V, defined as follows:

  1. If NAME1 is identical to NAME2, then V is the startupCost associated with NAME1
  2. If NAME1 is not identical to NAME2, then V is the startupCost associated with NAME1 plus the communicationCost associated with NAME1 plus the sum of the communicationCost associated with all the Router class objects between the objects associated with NAME1 and with NAME2. Note that NAME2 may come after or before NAME1.
If either NAME1 or NAME2 doesn't appear on the list, then V is -1.0. For example, the value V for (Mitsu, Bill) is 100.0+10.0+9.0 = 119.0 while the value V for (Bill, Mitsu) is 80.0+8.0+9.0=97.0