Question: Assignment Overview: You will be implementing a new version of a linked list. This is a linked list which has possible sublists descending from each
Assignment Overview:
You will be implementing a new version of a linked list. This is a linked list which has possible sublists descending from each node. These sublists are used to group together all nodes which share a common category value. You will be designing custom nodes with three categories on which to group. By the end, you will have a list which is similar to the one shown below.
NOTE: The number of nodes here is for demonstration only. Your list should be able to dynamically add new nodes either to the main list, or a specific sublist based on the criteria described in the rest of these directions.
Observe that the main list is doubly-linked, while the sub-lists are not.
TheNodeClass
TheNodeclass represents one "Node" of yourLinkedList. TheNodeclass must be Generic with three different type parameters. The Generic types could each be different, so you cannot use the same generic label for each type. An example of what I mean is demonstrated in the following Node instantiation:
Node
Also note that it is possible for the type parameters to be the same as well:
Node
Be sure to design the generics of your Node class accordingly.
The following defines the requirements for the Node class. You are not allowed to change / add / omit anything in the requirements.
Member VariablesThis class shall have one member variable calledcategory1which will store information related to the first grouping category. This data field shall begenericand shall havepackage-levelaccess.This class shall have one member variable calledcategory2which will store information related to the second grouping category. This data field shall begenericand shall havepackage-levelaccess.This class shall have one member variable calledcategory3which will store information related to the third grouping category. This data field shall begenericand shall havepackage-levelaccess.This class shall have one member variable calledrightwhich is a pointer to the next item in the main list. This data field shall havepackage-levelaccess.This class shall have one member variable calledleftwhich is a pointer to the previous item in the main list. This data field shall havepackage-levelaccess.This class shall have one member variable calleddownwhich is a pointer to the next item in the sub-list This data field shall havepackage-levelaccess.No other member variables are allowed.ConstructorThis class shall have one constructor which has parameters to initialize the three category data fields.No other constructors are allowed.Methods:This class shall have getters and setters for each of the three category variables.
NOTE: That all Node instantiation and manipulation will be done within your LinkedList class. The types for the parameters will also come from the corresponding generic parameters in the LinkedList class. Nodes will NOT be instantiated in any classes OTHER than LinkedList.
TheLinkedListClass
This will be the class which is responsible for all of the functionality of your LinkedList. This must be aGenericclass where the generic parameter types could each be different or could be the same for two or more types (similar requirements for the Node class). An example of instantiating a LinkedList might be:
LinkedList
NOTE: The type parameters will be the same type and in the same order as the type parameters for the Nodes for this list.
The key with properly designing this class is in how a new node is added to your list. All nodes will be grouped together based on one of the three categories from the Node class. At any given time, the user can choose how to group the nodes, and the initial grouping will always use the first category. Nodes which have the same value in the current grouping category. will be added to the same sub-list. Nodes which do not have the same value as any of the existing sub-lists will be added to the main list.
Example: Lets say I have five people P1, P2, P3, P4, and P5, and each person has the following values in their respective categories (age, eye color, profession):
P1: 25, blue, doctor P2: 34, brown, pilot P3: 25, brown, uber driver P4: 25, green, doctor P5: 34, green, uber driver
If I were to group my list based on the age category (category1), my list might look something like:
You should also be able to regroup your list based on the other two categories as well.
Member Variables:This class shall have one member variable calledheadwhich will store a pointer to the firstNodein the LinkedList.This class shall have one member variable calledsizewhich will store thetotalnumber of elements in the list (this includes all nodes in the main list as well as the sub lists). This should be aread-onlyproperty which cannot be changed outside of the LinkedList class.This class shall have one member variable calledcategory1Labelwhich will store the label for category1 from the Node class. This should be aread-onlyproperty which cannot be changed once the initial list has been created. In the above example, the label for category1 would be "Age".This class shall have one member variable calledcategory2Labelwhich will store the label for category2 from the Node class. This should be aread-onlyproperty which cannot be changed once the initial list has been created. In the above example, the label for category1 would be "Eye Color".This class shall have one member variable calledcategory3Labelwhich will store the label for category1 from the Node class. This should be aread-onlyproperty which cannot be changed once the initial list has been created. In the above example, the label for category1 would be "Profession".This class shall have one member variable calledgroupingCategorywhich will store the current category number upon which the list should be grouped. The default grouping category is category1.No other member variables are allowed.Constructors:This class shall have one no-arg constructor which creates an empty list.This class shall have one constructor which takes an integer parameter, which is the number of the current category upon which you want your list to group. This constructor should also create an empty list.This class shall have one constructor which takes aFileobject parameterand an integer parameter. This File is the input file from which a list can be generated and populated.The integer parameter is the current grouping property. See below for the required format of the input file. This constructor should take the File and create a list based on the values in the File.Methods:NOTE: These methods should be implemented with generics in mind. It will be your job to figure out how to do this.add(value1, value2, value3):This method shall have three parameters. These parameters are the values of the categories in a Node.Use the parameters to create a new Node and add it to the list.The Node must be added in such a way that it maintains the current grouping category of the list.clear():This method shall clear the list.deleteFirst():This method shall delete the first Node in the main list.This method shall NOT delete any nodes in the first Node's sublist. The remaining Nodes in the sublist should be "reattached" to the beginning of the main list.deleteLast():This method shall delete the last Node in the main list.This method shall NOT delete any nodes in the last Node's sublist. The remaining Nodes in the sublist should be "reattached" to the end of the main list.delete(mainIndex, subIndex):This method shall delete a specific node from anywhere in the list, given themainIndexandsubIndex.This method should ONLY delete the requested Node and should "reconnect" any Nodes that may be attached to the deleted Node.get(mainIndex, category):This method shall have an integer parameter,mainIndex, which is an index (starting from 0) which indicates theNodefrom themain branchyou want to retrieve.This method shall have another integer parameter,category, which is a category number (1 - 3) that will indicate which category's value you want to retrieve. This method shall return the chosen category value, from the chosen Node in the main list.The category value should be returned as a String.If the index is out of bounds, this method should throw anIndexOutOfBoundsExceptionwith an appropriate error message indicating whether it was the main index or category value that was out of bounds.get(mainIndex, subIndex, category):This method shall have an integer parameter,mainIndex, which is an index (starting from 0) which indicates theNodefrom themain branchyou want to retrieve.This method shall have an integer parameter,subIndex, which is an index (starting from 0) which indicates theNodefrom thesub-listof the chosen main branch Node.This method shall have another integer parameter,category, which is a category number (1 - 3) that will indicate which category's value you want to retrieve.This method shall return the value from the chosen category, in the indicated sub-list.The category value should be returned as a String.If any of the parameters are out of bounds, this method should throw anIndexOutOfBoundsExceptionwith an appropriate error message indicating whether it was the main index, sub index or category value that was out of bounds.regroup(groupingCategoryNumber):This method shall be responsible for regrouping your LinkedList based on the given regrouping category number.Example: I could take the above list from the diagram, which was initially grouped based on the Age category (category 1), and I could regroup the list based on the Profession category (category 3).If thegroupingCategoryNumberis out of bounds, display anIndexOutOfBoundsExceptionwith an appropriate error message.size():This method shall return the size of the main list.The size is the number of nodes in the main list.size(index):This method shall return the size of the sub-list at the given index.If the given index is out of bounds, this method should throw anIndexOutOfBoundsExceptionwith an appropriate error message.No other methods are allowed, except you may add atoString()method for testing purposes only.Input File FormatThe input file shall be in the following format:The first three lines of the file will be the labels of each categoryThe next line is a blank lineThe values for each category are comma separated, with one node's values per line.For testing purposes, please have at least 10 entries in your input file and make sure some of the categories have the same information so you can demonstrate the grouping aspect of the project.See this example:LINKThe GUIDesign a GUI which will display a graphical representation of your list. It should show the main list and any sub-lists in a diagram similar to what is pictured above.The "nodes" should also display the values of the three categories stored in a node.You must also provide a way for the user to manipulate the list using any of the previously designed methods.i.e. You need to provide buttons and textboxes / textfields for the functions in your LinkedList class.HINT: A GridPane may be useful to organize the parts of your LinkedList picture.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
