⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 roomnode.java

📁 一个用JAVA语言编写的迷宫程序,可以实现迷宫的行走
💻 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 + -