EOS 2  1.1.0
Einfache Objektbasierte Sprache
Roboter.java
gehe zur Dokumentation dieser Datei
1 
2 package eos;
3 
4 import de.lathanda.eos.robot.Robot;
5 import de.lathanda.eos.robot.exceptions.CubeImmutableException;
6 import de.lathanda.eos.robot.exceptions.CubeMissingException;
7 import de.lathanda.eos.robot.exceptions.RobotException;
8 import de.lathanda.eos.robot.exceptions.RobotMovementFailedException;
9 import de.lathanda.eos.robot.exceptions.RobotVoidException;
10 import eos.ausnahmen.BewegungFehlgeschlagenAusnahme;
11 import eos.ausnahmen.KeinSteinVorhandenAusnahme;
12 import eos.ausnahmen.RoboterAusnahme;
13 import eos.ausnahmen.RoboterOhneWeltAusnahme;
14 import eos.ausnahmen.SteinFeststehendAusnahme;
15 
33 public class Roboter {
34  protected Robot robot;
35 
36  public Roboter() {
37  robot = new Robot();
38  }
39 
40  public void schritt() {
41  try {
42  robot.step();
43  } catch (RobotMovementFailedException e) {
44  throw new BewegungFehlgeschlagenAusnahme(e);
45  } catch (RobotVoidException e) {
46  throw new RoboterOhneWeltAusnahme(e);
47  } catch (RobotException re) {
48  throw new RoboterAusnahme(re);
49  }
50  }
51 
52  public void schritt(int anzahl) {
53  try {
54  robot.step(anzahl);
55  } catch (RobotMovementFailedException e) {
56  throw new BewegungFehlgeschlagenAusnahme(e);
57  } catch (RobotVoidException e) {
58  throw new RoboterOhneWeltAusnahme(e);
59  } catch (RobotException re) {
60  throw new RoboterAusnahme(re);
61  }
62  }
63  public void schrittZurueck() {
64  try {
65  robot.stepBack();
66  } catch (RobotMovementFailedException e) {
67  throw new BewegungFehlgeschlagenAusnahme(e);
68  } catch (RobotVoidException e) {
69  throw new RoboterOhneWeltAusnahme(e);
70  } catch (RobotException re) {
71  throw new RoboterAusnahme(re);
72  }
73  }
74  public void schrittLinks() {
75  try {
76  robot.stepLeft();
77  } catch (RobotMovementFailedException e) {
78  throw new BewegungFehlgeschlagenAusnahme(e);
79  } catch (RobotVoidException e) {
80  throw new RoboterOhneWeltAusnahme(e);
81  } catch (RobotException re) {
82  throw new RoboterAusnahme(re);
83  }
84  }
85  public void schrittRechts() {
86  try {
87  robot.stepRight();
88  } catch (RobotMovementFailedException e) {
89  throw new BewegungFehlgeschlagenAusnahme(e);
90  } catch (RobotVoidException e) {
91  throw new RoboterOhneWeltAusnahme(e);
92  } catch (RobotException re) {
93  throw new RoboterAusnahme(re);
94  }
95  }
96  public void runterFliegen() {
97  try {
98  robot.flyDown();
99  } catch (RobotMovementFailedException e) {
100  throw new BewegungFehlgeschlagenAusnahme(e);
101  } catch (RobotVoidException e) {
102  throw new RoboterOhneWeltAusnahme(e);
103  } catch (RobotException re) {
104  throw new RoboterAusnahme(re);
105  }
106  }
107  public void hochFliegen() {
108  try {
109  robot.flyUp();
110  } catch (RobotMovementFailedException e) {
111  throw new BewegungFehlgeschlagenAusnahme(e);
112  } catch (RobotVoidException e) {
113  throw new RoboterOhneWeltAusnahme(e);
114  } catch (RobotException re) {
115  throw new RoboterAusnahme(re);
116  }
117  }
118  public void linksFliegen() {
119  try {
120  robot.flyLeft();
121  } catch (RobotMovementFailedException e) {
122  throw new BewegungFehlgeschlagenAusnahme(e);
123  } catch (RobotVoidException e) {
124  throw new RoboterOhneWeltAusnahme(e);
125  } catch (RobotException re) {
126  throw new RoboterAusnahme(re);
127  }
128  }
129  public void rechtsFliegen() {
130  try {
131  robot.flyRight();
132  } catch (RobotMovementFailedException e) {
133  throw new BewegungFehlgeschlagenAusnahme(e);
134  } catch (RobotVoidException e) {
135  throw new RoboterOhneWeltAusnahme(e);
136  } catch (RobotException re) {
137  throw new RoboterAusnahme(re);
138  }
139  }
140  public void fliegen() {
141  try {
142  robot.fly();
143  } catch (RobotMovementFailedException e) {
144  throw new BewegungFehlgeschlagenAusnahme(e);
145  } catch (RobotVoidException e) {
146  throw new RoboterOhneWeltAusnahme(e);
147  } catch (RobotException re) {
148  throw new RoboterAusnahme(re);
149  }
150  }
151  public void zurueckFliegen() {
152  try {
153  robot.flyBack();
154  } catch (RobotMovementFailedException e) {
155  throw new BewegungFehlgeschlagenAusnahme(e);
156  } catch (RobotVoidException e) {
157  throw new RoboterOhneWeltAusnahme(e);
158  } catch (RobotException re) {
159  throw new RoboterAusnahme(re);
160  }
161  }
162  public void linksdrehen() {
163  robot.turnLeft();
164  }
165 
166  public void rechtsdrehen() {
167  robot.turnRight();
168  }
169  public void umdrehen() {
170  robot.turnAround();
171  }
172 
173  public void hinlegen() {
174  try {
175  robot.dropStone();
176  } catch (RobotVoidException e) {
177  throw new RoboterOhneWeltAusnahme(e);
178  } catch (RobotException re) {
179  throw new RoboterAusnahme(re);
180  }
181  }
182 
183  public void aufheben() {
184  try {
185  robot.pickup();
186  } catch (RobotVoidException e) {
187  throw new RoboterOhneWeltAusnahme(e);
188  } catch (CubeMissingException e) {
189  throw new KeinSteinVorhandenAusnahme(e);
190  } catch (CubeImmutableException e) {
191  throw new SteinFeststehendAusnahme(e);
192  } catch (RobotException re) {
193  throw new RoboterAusnahme(re);
194  }
195  }
196  public void aufheben(int n) {
197  try {
198  robot.pickup(n);
199  } catch (RobotVoidException e) {
200  throw new RoboterOhneWeltAusnahme(e);
201  } catch (CubeMissingException e) {
202  throw new KeinSteinVorhandenAusnahme(e);
203  } catch (CubeImmutableException e) {
204  throw new SteinFeststehendAusnahme(e);
205  } catch (RobotException re) {
206  throw new RoboterAusnahme(re);
207  }
208  }
209  public void steinSetzen(int n) {
210  try {
211  robot.placeStone(n);
212  } catch (RobotVoidException e) {
213  throw new RoboterOhneWeltAusnahme(e);
214  } catch (CubeImmutableException e) {
215  throw new SteinFeststehendAusnahme(e);
216  } catch (RobotException re) {
217  throw new RoboterAusnahme(re);
218  }
219  }
220  public void steinEntfernen(int n) {
221  try {
222  robot.removeStone(n);
223  } catch (RobotVoidException e) {
224  throw new RoboterOhneWeltAusnahme(e);
225  } catch (CubeImmutableException e) {
226  throw new SteinFeststehendAusnahme(e);
227  } catch (RobotException re) {
228  throw new RoboterAusnahme(re);
229  }
230  }
231  public void farbeSetzen(Farbe farbe) {
232  robot.setRobotColor(farbe.getColor());
233  }
234  public Farbe farbeLesen() {
235  return new Farbe(robot.getRobotColor());
236  }
237  public void steinFarbeSetzen(Farbe farbe) {
238  robot.setStoneColor(farbe.getColor());
239  }
240 
241  public void markeSetzen() {
242  try {
243  robot.setMark();
244  } catch (RobotVoidException e) {
245  throw new RoboterOhneWeltAusnahme(e);
246  } catch (RobotException re) {
247  throw new RoboterAusnahme(re);
248  }
249  }
250  public void markeSetzen(Farbe farbe) {
251  try {
252  robot.setMark(farbe.getColor());
253  } catch (RobotVoidException e) {
254  throw new RoboterOhneWeltAusnahme(e);
255  } catch (RobotException re) {
256  throw new RoboterAusnahme(re);
257  }
258  }
259 
260  public void markeLoeschen() {
261  try {
262  robot.removeMark();
263  } catch (RobotVoidException e) {
264  throw new RoboterOhneWeltAusnahme(e);
265  } catch (RobotException re) {
266  throw new RoboterAusnahme(re);
267  }
268  }
269  public boolean istMarke() {
270  try {
271  return robot.isMarked();
272  } catch (RobotVoidException e) {
273  throw new RoboterOhneWeltAusnahme(e);
274  } catch (RobotException re) {
275  throw new RoboterAusnahme(re);
276  }
277  }
278  public boolean istMarke(Farbe farbe) {
279  try {
280  return robot.isMarked(farbe.getColor());
281  } catch (RobotVoidException e) {
282  throw new RoboterOhneWeltAusnahme(e);
283  } catch (RobotException re) {
284  throw new RoboterAusnahme(re);
285  }
286  }
287  public boolean istFrei() {
288  try {
289  return robot.isFree();
290  } catch (RobotVoidException e) {
291  throw new RoboterOhneWeltAusnahme(e);
292  } catch (RobotException re) {
293  throw new RoboterAusnahme(re);
294  }
295  }
296  public boolean istLinksFrei() {
297  try {
298  return robot.isLeftFree();
299  } catch (RobotVoidException e) {
300  throw new RoboterOhneWeltAusnahme(e);
301  } catch (RobotException re) {
302  throw new RoboterAusnahme(re);
303  }
304  }
305  public boolean istRechtsFrei() {
306  try {
307  return robot.isRightFree();
308  } catch (RobotVoidException e) {
309  throw new RoboterOhneWeltAusnahme(e);
310  } catch (RobotException re) {
311  throw new RoboterAusnahme(re);
312  }
313  }
314  public boolean istHintenFrei() {
315  try {
316  return robot.isBackFree();
317  } catch (RobotVoidException e) {
318  throw new RoboterOhneWeltAusnahme(e);
319  } catch (RobotException re) {
320  throw new RoboterAusnahme(re);
321  }
322  }
323  public boolean istObenFrei() {
324  try {
325  return robot.isTopFree();
326  } catch (RobotVoidException e) {
327  throw new RoboterOhneWeltAusnahme(e);
328  } catch (RobotException re) {
329  throw new RoboterAusnahme(re);
330  }
331  }
332  public boolean istUntenFrei() {
333  try {
334  return robot.isBottomFree();
335  } catch (RobotVoidException e) {
336  throw new RoboterOhneWeltAusnahme(e);
337  } catch (RobotException re) {
338  throw new RoboterAusnahme(re);
339  }
340  }
341  public boolean istHindernis() {
342  try {
343  return robot.isObstacle();
344  } catch (RobotVoidException e) {
345  throw new RoboterOhneWeltAusnahme(e);
346  } catch (RobotException re) {
347  throw new RoboterAusnahme(re);
348  }
349  }
350  public boolean istHintenHindernis() {
351  try {
352  return robot.isBackObstacle();
353  } catch (RobotVoidException e) {
354  throw new RoboterOhneWeltAusnahme(e);
355  } catch (RobotException re) {
356  throw new RoboterAusnahme(re);
357  }
358  }
359  public boolean istLinksHindernis() {
360  try {
361  return robot.isLeftObstacle();
362  } catch (RobotVoidException e) {
363  throw new RoboterOhneWeltAusnahme(e);
364  } catch (RobotException re) {
365  throw new RoboterAusnahme(re);
366  }
367  }
368  public boolean istRechtsHindernis() {
369  try {
370  return robot.isRightObstacle();
371  } catch (RobotVoidException e) {
372  throw new RoboterOhneWeltAusnahme(e);
373  } catch (RobotException re) {
374  throw new RoboterAusnahme(re);
375  }
376  }
377  public boolean istStein() {
378  try {
379  return robot.hasStone();
380  } catch (RobotVoidException e) {
381  throw new RoboterOhneWeltAusnahme(e);
382  } catch (RobotException re) {
383  throw new RoboterAusnahme(re);
384  }
385  }
386  public boolean istStein(int n) {
387  try {
388  return robot.hasStone(n);
389  } catch (RobotVoidException e) {
390  throw new RoboterOhneWeltAusnahme(e);
391  } catch (RobotException re) {
392  throw new RoboterAusnahme(re);
393  }
394  }
395  public boolean istSueden() {
396  return robot.isFacingSouth();
397  }
398  public boolean istWesten() {
399  return robot.isFacingWest();
400  }
401  public boolean istNorden() {
402  return robot.isFacingNorth();
403  }
404  public boolean istOsten() {
405  return robot.isFacingEast();
406  }
407  public Farbe steinFarbe() {
408  try {
409  return new Farbe(robot.stoneColor());
410  } catch (RobotVoidException e) {
411  throw new RoboterOhneWeltAusnahme(e);
412  } catch (RobotException re) {
413  throw new RoboterAusnahme(re);
414  }
415  }
416 }
final void turnRight()
Definition: Robot.java:229
final boolean isMarked()
Definition: Robot.java:209
void setStoneColor(MutableColor c)
Definition: Robot.java:481
final void dropStone()
Definition: Robot.java:166
final void removeMark()
Definition: Robot.java:159
final void turnAround()
Definition: Robot.java:235
void setRobotColor(MutableColor robotColor)
Definition: Robot.java:536
MutableColor getRobotColor()
Definition: Robot.java:533
boolean istHindernis()
Definition: Roboter.java:341
void linksFliegen()
Definition: Roboter.java:118
Robot robot
Definition: Roboter.java:34
boolean istMarke(Farbe farbe)
Definition: Roboter.java:278
boolean istStein(int n)
Definition: Roboter.java:386
void schrittLinks()
Definition: Roboter.java:74
void rechtsFliegen()
Definition: Roboter.java:129
void aufheben()
Definition: Roboter.java:183
boolean istRechtsHindernis()
Definition: Roboter.java:368
void rechtsdrehen()
Definition: Roboter.java:166
Farbe farbeLesen()
Definition: Roboter.java:234
void runterFliegen()
Definition: Roboter.java:96
boolean istMarke()
Definition: Roboter.java:269
boolean istStein()
Definition: Roboter.java:377
void aufheben(int n)
Definition: Roboter.java:196
void schrittRechts()
Definition: Roboter.java:85
boolean istFrei()
Definition: Roboter.java:287
boolean istRechtsFrei()
Definition: Roboter.java:305
void fliegen()
Definition: Roboter.java:140
void markeSetzen()
Definition: Roboter.java:241
boolean istNorden()
Definition: Roboter.java:401
void markeLoeschen()
Definition: Roboter.java:260
void schritt(int anzahl)
Definition: Roboter.java:52
void steinSetzen(int n)
Definition: Roboter.java:209
boolean istLinksFrei()
Definition: Roboter.java:296
void steinEntfernen(int n)
Definition: Roboter.java:220
void steinFarbeSetzen(Farbe farbe)
Definition: Roboter.java:237
boolean istHintenFrei()
Definition: Roboter.java:314
boolean istLinksHindernis()
Definition: Roboter.java:359
void zurueckFliegen()
Definition: Roboter.java:151
void umdrehen()
Definition: Roboter.java:169
void linksdrehen()
Definition: Roboter.java:162
void hochFliegen()
Definition: Roboter.java:107
void farbeSetzen(Farbe farbe)
Definition: Roboter.java:231
boolean istUntenFrei()
Definition: Roboter.java:332
boolean istOsten()
Definition: Roboter.java:404
void hinlegen()
Definition: Roboter.java:173
void schritt()
Definition: Roboter.java:40
boolean istHintenHindernis()
Definition: Roboter.java:350
Farbe steinFarbe()
Definition: Roboter.java:407
boolean istObenFrei()
Definition: Roboter.java:323
boolean istSueden()
Definition: Roboter.java:395
void markeSetzen(Farbe farbe)
Definition: Roboter.java:250
boolean istWesten()
Definition: Roboter.java:398
void schrittZurueck()
Definition: Roboter.java:63
Impressum