-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFigur.java
More file actions
47 lines (43 loc) · 854 Bytes
/
Figur.java
File metadata and controls
47 lines (43 loc) · 854 Bytes
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
class Figur
{
String farbe;
int x;
int y;
Figur(String f, int startX, int startY)
{
farbe = f;
x = startX;
y = startY;
}
void druckePosition()
{
System.out.println("Figur mit farbe " + farbe + " bei " + x + " " + y);
}
boolean gewonnen()
{
if(x == 0 && y == 0)
return true;
else
return false;
}
void gehe(int richtung)
{
if(richtung == 0)
y++;
if(richtung == 1)
x++;
if(richtung == 2)
y--;
if(richtung == 3)
x--;
// Springe falls notwendig an das andere Ende des Spielfeldes
if(x < -2)
x = 2;
if(x > 2)
x = -2;
if(y < -2)
y = 2;
if(y > 2)
y = -2;
}
}