Skip to content
Snippets Groups Projects
Commit 20e0f23c authored by Christoph Król's avatar Christoph Król
Browse files

Added Deck 4

parent ba14ba4f
No related branches found
No related tags found
No related merge requests found
import codescape.Dogbot;
public class MyDogbot extends Dogbot {
/**
* Der Funktion run() wird ein Paramter überreicht
* @param keys Array mit Passwort-Strings für die vier Konsolen
*/
public void run(String[] keys) {
// Dein Code hier:
/* Zahlen:
* 0 -> move();
* 1 -> turnLeft();
* 2 -> turnRight();
*/
moves("0001");
write(keys[0]);
moves("2001");
write(keys[1]);
moves("2002000202");
write(keys[2]);
moves("1002");
write(keys[3]);
moves("10000");
}
void moves(String steps){
String moves = steps;
for (int i = 0; i < moves.length(); i ++){
char step = moves.charAt(i);
switch (step){
case '0':
move();
break;
case '1':
turnLeft();
break;
case '2':
turnRight();
break;
case '3':
pickUp();
break;
}
}
}
}
\ No newline at end of file
import codescape.Dogbot;
public class MyDogbot extends Dogbot {
/**
* Der Funktion run() wird ein Paramter überreicht,
* der zum Lösen des Raums benötigt wird.
* @param nr Nummer des Teleporters, der zum Ausgang führt
*/
public void run(int nr) {
// Dein Code hier:
System.out.print(nr);
switch (nr) {
case 1:
moves("00100020010022030");
break;
case 2:
moves("001000200200030");
case 3:
moves("00200010010022030");
case 4:
moves("002000100200030");
}
}
void moves(String steps){
String moves = steps;
for (int i = 0; i < moves.length(); i ++){
char step = moves.charAt(i);
switch (step){
case '0':
move();
break;
case '1':
turnLeft();
break;
case '2':
turnRight();
break;
case '3':
pickUp();
break;
}
}
}
}
\ No newline at end of file
import codescape.Dogbot;
public class MyDogbot extends Dogbot {
public void run() {
// Einlesen des Strings und Bewegung des RB zum Beginn des Labyrinths
move();
turnLeft();
/**
* gelesen wird ein Wort, das aus den Buchstaben "L", "M" und "R" besteht
* getrennt werden die Buchstaben durch ein Komma
* die Variable "weg" könnte so aussehen: "M,L,M,M,R,M"
*/
String weg = read();
for (int i=0; i<2; i++) {
turnRight();
}
String[] path = weg.split(",");
for(String moves : path){
switch (moves){
case "L":
turnLeft();
break;
case "R":
turnRight();
break;
case "M":
move();
break;
}
}
move();
turnLeft();
move();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment