EOS 2  1.1.0
Einfache Objektbasierte Sprache
Cube.java
gehe zur Dokumentation dieser Datei
1 package de.lathanda.eos.robot;
2 
3 import de.lathanda.eos.base.MutableColor;
4 import de.lathanda.eos.robot.exceptions.CubeImmutableException;
5 
12 public class Cube {
13  private MutableColor color;
14  private int type;
15  private boolean free;
16  private Cube(int type) {
17  this.type = type;
18  }
19 
20  public boolean isFree() {
21  return free;
22  }
23  public boolean isEmpty() {
24  return type == 0;
25  }
26  public void setEmpty() throws CubeImmutableException {
27  if (type == 3) {
28  throw new CubeImmutableException();
29  } else {
30  type = 0;
31  free = true;
32  }
33  }
34 
36  return color;
37  }
38  public int getType() {
39  return type;
40  }
41  public static Cube createCube(int type, MutableColor color) {
42  Cube cube = new Cube(type);
43  cube.color = color;
44  cube.free = type == 0;
45  return cube;
46  }
47  public static Cube createStone(MutableColor stoneColor) {
48  Cube cube = new Cube(2);
49  cube.color = stoneColor;
50  cube.free = false;
51  return cube;
52  }
53  public static Cube createRock(MutableColor stoneColor) {
54  Cube cube = new Cube(3);
55  cube.color = stoneColor;
56  cube.free = false;
57  return cube;
58  }
59  public static Cube createEmpty() {
60  Cube cube = new Cube(0);
61  cube.color = MutableColor.BLACK;
62  cube.free = true;
63  return cube;
64  }
65  public static Cube createGround() {
66  Cube cube = new Cube(1);
67  cube.color = MutableColor.DIRTY_BROWN;
68  cube.free = false;
69  return cube;
70  }
71 }
static final MutableColor BLACK
static final MutableColor DIRTY_BROWN
static Cube createStone(MutableColor stoneColor)
Definition: Cube.java:47
static Cube createRock(MutableColor stoneColor)
Definition: Cube.java:53
MutableColor getColor()
Definition: Cube.java:35
static Cube createCube(int type, MutableColor color)
Definition: Cube.java:41
static Cube createEmpty()
Definition: Cube.java:59
static Cube createGround()
Definition: Cube.java:65
Impressum