forked from 11sloe/Snake
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKnoten.java
More file actions
56 lines (46 loc) · 1.02 KB
/
Knoten.java
File metadata and controls
56 lines (46 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import javafx.scene.canvas.GraphicsContext;
public class Knoten
{
private SnakeElement inhalt;
private Knoten naechster;
public Knoten(SnakeElement inhalt_)
{
inhalt = inhalt_;
naechster = null;
}
public void setNaechster(Knoten naechster_)
{
naechster = naechster_;
}
public void zeichnen(GraphicsContext gc)
{
inhalt.zeichnen(gc);
if(naechster!=null){
naechster.zeichnen(gc);
}
}
public void einfuegen(SnakeElement elem)
{
if(naechster==null){
naechster = new Knoten(elem);
}else{
naechster.einfuegen(elem);
}
}
public boolean trifft(int x, int y)
{
if (inhalt.trifft(x,y))
{
return true;
}
if(naechster != null)
{
return naechster.trifft(x,y);
}
return false;
}
public Knoten getNaechster()
{
return naechster;
}
}