Thirumalai P. Varadan (email@example.com)
April 30, 2000
This is the design of a N-ary Tree. The user can enter the various nodes of the tree and he can choose how many nodes he wants at each level and then he can choose to didplay the whole tree or a sub-tree of the given tree. The tree that is displayed is always done so at the top right corner of the screen. The tree is not drawn in a seperate window. The tree has a limitation as to the number of tree node depths that it can display. After a certain depth the nodes start overlapping. The user can enter the fata that the tree has to store at each node but the tree does not check for the overlap of the data entered by the user while displaying the tree.
Tree: This is a god object. This class pretty much does everything that the project is supposed to do. This class represents a node of the N-ary tree. This class a variable that is concerned with storing the data that a node is supposed to store. This node also has an ordered collection. This ordered collection stores the list of children for the given node. Every node knows its children but no node knows its parent. Every node has a display method which is called by the user when he wants to see that node and all its children. This method draws the node and then calls the display method of all its children recursively.
1. All that I did when this project wa given out, is realize that a tree is made up of many node each node being essentially the same. So I decided to make a class called Tree that represents the node in a n-ary tree. I also included the display methods inside the node. So what I ended up was with a huge monolithic class that did all the job necessary. This was not at all object oriented programming byt rather the procedural programming only.
|This class gets the input from the user adds it to itself and displays it on the screen|
a) If the nodes that the user enters is within the normal limit, then the tree would space it properly and display it.
b)If the user enters too many nodes at a given horizontal level, then the tree would say that it cannot display the nodes properly and will not display all the nodes that donot fit into the screen.
c) If the user enters too many nodes such that the tree grows deep down then when the limit is reached, the tree will display a method saying that the maximum depth has been exceeded and will not display anything beyond a particular depth.
d) If the user at any node enters an etrememly long data, then the tree will not detect the overlappimng display and will screw up the display.
1. The Tree method can be used to display a network nodes, if the nodes are present in a tree like fashion.
2. The tree class alone without the display methods can be used as a N-Ary tree data structure.
The tree as such is of limited reusability since it was built for a specific purpose of this assignment and this because of the monolithic class structure of the Tree class. The whole design has a god object and hence because of this, the reusability has been greatly hampered.