home *** CD-ROM | disk | FTP | other *** search
- class MapNode
- {
- var arrChildren;
- var strLabel;
- var intIterator;
- var nodeData;
- var parentNode;
- function MapNode()
- {
- this.arrChildren = new Array();
- this.strLabel = "";
- this.intIterator = -1;
- this.nodeData = new StateData();
- }
- function GetParent()
- {
- return this.parentNode;
- }
- function SetParent(newParent)
- {
- this.parentNode = newParent;
- }
- function AddChild()
- {
- var _loc2_ = new MapNode();
- _loc2_.SetParent(this);
- this.arrChildren.push(_loc2_);
- if(this.arrChildren.length > 0)
- {
- this.intIterator = this.arrChildren.length - 1;
- }
- }
- function PointToNode(node)
- {
- node.SetParent(this);
- this.arrChildren.push(node);
- if(this.arrChildren.length > 0)
- {
- this.intIterator = this.arrChildren.length - 1;
- }
- }
- function Print()
- {
- var _loc2_ = 0;
- while(_loc2_ < this.arrChildren.length)
- {
- this.arrChildren[_loc2_].Print();
- _loc2_ = _loc2_ + 1;
- }
- }
- function Reset()
- {
- if(this.arrChildren.length > 0)
- {
- this.intIterator = 0;
- }
- else
- {
- this.intIterator = -1;
- }
- var _loc2_ = 0;
- while(_loc2_ < this.arrChildren.length)
- {
- this.arrChildren[_loc2_].Reset();
- _loc2_ = _loc2_ + 1;
- }
- }
- function GetChild()
- {
- if(this.intIterator != -1)
- {
- return this.arrChildren[this.intIterator];
- }
- return undefined;
- }
- function NextChild()
- {
- this.intIterator = this.intIterator + 1;
- if(this.intIterator >= this.arrChildren.length)
- {
- if(this.arrChildren.length == 0)
- {
- this.intIterator = -1;
- }
- else
- {
- this.intIterator = 0;
- }
- return false;
- }
- return true;
- }
- function PrevChild()
- {
- this.intIterator = this.intIterator - 1;
- if(this.intIterator < 0)
- {
- if(this.arrChildren.length == 0)
- {
- this.intIterator = -1;
- }
- else
- {
- this.intIterator = this.arrChildren.length - 1;
- }
- return false;
- }
- return true;
- }
- function FirstChild()
- {
- if(this.arrChildren.length == 0)
- {
- this.intIterator = -1;
- return false;
- }
- this.intIterator = 0;
- return true;
- }
- function GetNumChildren()
- {
- return this.arrChildren.length;
- }
- function PrintPathTest()
- {
- var _loc2_ = this.strLabel + ", ";
- if(this.arrChildren.length > 0)
- {
- var _loc3_ = Math.round(Math.random() * (this.arrChildren.length - 1));
- _loc2_ += this.arrChildren[_loc3_].PrintPathTest();
- }
- return _loc2_;
- }
- function GetLabel()
- {
- return this.strLabel;
- }
- function SetLabel(newLabel)
- {
- this.strLabel = newLabel;
- }
- }
-