Iterator Pattern Code Review

Define the Node and Person Objects

Code Review

Code Walkthrough

The Node class (object) represents the definition of a node in the tree structure.

class Node { public Node Child { get; set; } public Node Next { get; set; } public Person Data { get; set; }
public Node(Person data, Node child, Node next) { this.Data = data; this.Child = child; this.Next = next; } }

The Child property represents the first child node of the current node. The Next property represents the node to the right of the current node. The Data property represents the data stored for a particular node.

The Person class (object) represents the custom properties required for a person stored in the tree structure.

class Person { public String Name { get; set; } public Int32 Birth { get; set; }
public Person(String name, Int32 birth) { this.Name = name; this.Birth = birth; }
public override string ToString() { return (String.Format("[{0}, {1}]", this.Name, this.Birth)); } }