📄 roomnode.java
字号:
/**
*
*/
package org.freemind.maze2d;
/**
* @author Jerric
* @created Feb 9, 2006
*/
public class RoomNode {
private int roomX;
private int roomY;
private RoomNode parent;
/**
* The height of a tree. This value is only valid on the root node, and it
* records the height of the internal tree of the set where the root node
* belongs to.
*/
private int height;
/**
*
*/
public RoomNode(int roomX, int roomY) {
this.roomX = roomX;
this.roomY = roomY;
height = 0;
parent = null;
}
/**
* @param parent The parent to set.
*/
public void setChild(RoomNode child) {
child.parent = this;
// update the tree height of the parent
height = Math.max(height, child.height + 1);
}
/**
* @return Returns the roomX.
*/
public int getRoomX() {
return this.roomX;
}
/**
* @return Returns the roomY.
*/
public int getRoomY() {
return this.roomY;
}
/**
* @return Returns the height.
*/
public int getHeight() {
return this.height;
}
public RoomNode getRoot() {
RoomNode n = this;
RoomNode p = this.parent;
// trace back to the root, whose parent is null
while (p != null) {
n = p;
p = n.parent;
}
return n;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -