Commit 3f472c37 authored by Stefan Michel's avatar Stefan Michel

testing

parent b977ca6e
#Wed Jan 31 12:32:00 CET 2018
#Wed Jan 31 12:45:06 CET 2018
tutorport=3579
tutorhost=localhost
language=en
role=student
language=de
package controller;
import application.Main;
import model.Terrain;
import model.exceptions.NoCornException;
public class HamsterController {
......@@ -12,11 +14,19 @@ public class HamsterController {
}
public void pickUp() {
terrain.getHamster().pickUp();
try {
terrain.getHamster().pickUp();
} catch (NoCornException e) {
Main.playDeathSound();
}
}
public void putDown() {
terrain.getHamster().putDown();
try {
terrain.getHamster().putDown();
} catch (RuntimeException e) {
Main.playDeathSound();
}
}
public void turnLeft() {
......@@ -24,10 +34,10 @@ public class HamsterController {
}
public void forward() {
terrain.getHamster().forward();
}
public int getHamsterCorns() {
return terrain.getHamsterCorns();
try {
terrain.getHamster().forward();
} catch (Exception e) {
Main.playDeathSound();
}
}
}
......@@ -76,10 +76,13 @@ public class SetFileNameDialogBox {
Optional<String> result = dialog.showAndWait();
result.ifPresent(res -> {
Main.startNewStage(res, terrain);
if (ioController != null)
Terrain newterrain = new Terrain();
newterrain.setUpTerrain(terrain);
if (ioController != null) {
ioController.saveFile(res);
}
Main.activePrograms.add(res);
Main.startNewStage(res, newterrain);
});
......
......@@ -40,21 +40,15 @@ public class TerrainController {
}
public void addWall(int col, int row) {
synchronized (this) {
terrain.addWall(col, row);
}
terrain.addWall(col, row);
}
public void moveHamster(int col, int row) {
synchronized (this) {
terrain.setHamsterPostion(col, row);
}
terrain.setHamsterPostion(col, row);
}
public void deleteTile(int col, int row) {
synchronized (this) {
terrain.deleteTile(col, row);
}
terrain.deleteTile(col, row);
}
public void serializeTerrain() {
......
......@@ -106,6 +106,7 @@ public class Hamster extends Thread {
try {
main();
} catch (RuntimeException e) {
Main.playDeathSound();
this.stopHamster();
}
running = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment