My job was to:
Revise the Node class to a generic one so that it can handle folders and files in a file system shown below.
And also:
First, you need to modify the Node class so that both ‘size’ and ‘name’ will be replaced by one object.
Now, I did the first part where we change the class to use generic types. I’m stuck at second problem. I don’t know how to pass single object instead of 2 variables and then do bunch of computation within it.
How would I substitute multiple variables for single object here? I’ve been trying to change types and move things around but my code keeps failing as soon as I remove those 2 variables.
Code:
class Node<T>
{
public String name;
public int size;
public Node<T> leftChild;
public Node<T> rightChild;
public void displayNode()
{
System.out.print('{');
System.out.print(name);
System.out.print(", ");
System.out.print(size);
System.out.print("} ");
}
} // end class Node
I would redesign it like this:
EDIT One way to rewrite your
findmethod is for it to find a particularTvalue: