View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Tree Milestone Case


Tree Project


Thirumalai P. Varadan (



April 30, 2000

OOA Analysis

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.




Responsibility Collaborator
This class gets the input from the user adds it to itself and displays it on the screen



  • children - This is an ordered collection that has the list of all the children of a particular node
  • data - This is a variable that contains the data stored at the particular node
  • depthMax - This is a variable used to store the depth of a particular node in a tree.
  • addNode: This method adds a node to the existing tree
  • at: This method returns the children node at any specified index.
  • content: This method is used to set the data stored at any node in a given tree
  • display This method is the one which is called to display a tree
  • displayHelperFrom:to:wide:size:sibling This method helps the display method to draw out the tree and this method uses recursion to draw the tree out.
  • drawLineFrom:to: Draws line starting from the from point to the to point on the screen.
  • first ---Returns the first child of the current node
  • last ---Returns th elast child of the current node


1. The user can add as many nodes he wants to the tree at any level he wants.

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.

OOD Diagram

Uploaded Image: dan.gif
The source code for the tree project

Missing File (/cs2340/uploads/

Link to this Page