Question: To complete this project, you need to implement the following classes. The details of each class are explained below. The classes in this assignment should

To complete this project, you need to implement the following classes. The details of each class are explained below. The classes in this assignment should be named by replacing with the actual name of your item. For example, if you choose to implement a collection of pets, then your classes should be named Pet, Dog, Cat, PetNode, PetOrderedList, PetOrderedListDriver, PetTypesLists, and PetTypesListsDriver.
,, and : these must be the same item and subitem classes that you used in Assignment 2. If you did not complete Assignment 2, go back and implement only Part 2 of Assignment 2.
Node: a linked list node where the data part is of type Item.
OrderedList: a linked list of Node.
TypesLists: a collection class that has two lists of type OrderedList, one to store items of type and the other to store items of type .
OrderedListDriver: a Java class that includes only a main method to test the functionality of your OrderedList class.
TypesListsDriver: a Java class that includes only a main method to test the functionality of your TypesLists class.
Note: Design note on the class
Since all Items must be of one or other subitem type (e.g., each Pet must be a Dog or a Cat), theoretically the class should be declared as an abstract class, so that no one can instantiate an Item that is not a subitem. However, making the Item class abstract would break your existing code for Assignment 2, so you will have to check that each Item is a proper subitem in your code.[1]
Part 1: Implement class Node
The Node class represents a node in the linked list. The class should include the following:
Instance variables;
private Item data;
the data item stored at this Node. It is fine to use a term that relates to the Item here instead of the word data. For instance, if your Item is a Pet, you might want to say Pet myPet;
private Node link
a reference to the next node in the linked list
Constructor:
public Node( Item i, Node n )
Initializes the two instance variables.
Methods:
public getters and setters for the instance variables: getData, getLink, setData, setLink.
[1] This is an example of a design tradeoff. In order to not break existing code, we dont do the implementation in the simplest way possible. Another, possibly better way to do this in real life would be to go back to assignment 2, make the Item class abstract, and include a third subclass Other for items that are not of type ItemA or ItemB.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!