node.java
来自「贪吃蛇java版本。自己写的」· Java 代码 · 共 78 行
JAVA
78 行
import java.awt.Color;
import java.awt.Graphics;
public class Node {
private int x;
private int y;
private Node next;
public Node(int x, int y, Node next)
{
this.x = x;
this.y = y;
this.next = next;
}
public Node(int x, int y)
{
this.x = x;
this.y = y;
this.next = null;
}
public Node()
{
this.x = 0;
this.y = 0;
this.next = null;
}
public void setX(int x)
{
this.x = x;
}
public void setY(int y)
{
this.y = y;
}
public int getX()
{
return this.x;
}
public int getY()
{
return this.y;
}
public Node getNext()
{
return this.next;
}
public void setNext(Node next)
{
this.next = next;
}
public boolean equals(Node aNode)
{
if(this.x == aNode.x && this.y == aNode.y)
return true;
else
return false;
}
public void display(Graphics g)
{
g.setColor(Color.BLUE);
g.drawRect(10 * x, 10 * y, 10, 10);
g.setColor(Color.RED);
g.fillRect(10 * x + 1, 10 * y + 1, 9, 9);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?