Commit 487fe05c authored by Stefan Michel's avatar Stefan Michel

Controller interfaces geloescht da unnoetig

parent 44e6ce48
package application;
import controller.*;
import controller.HamsterController;
import controller.IOController;
import controller.TerrainController;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
......@@ -16,10 +18,10 @@ import java.util.List;
public class Main extends Application {
private Terrain terrain;
private ITerrainController terrainController;
private IHamsterController hamsterController;
private TerrainController terrainController;
private HamsterController hamsterController;
public static final List<String> activePrograms = new ArrayList<>();
private IInputOutputController ioController;
private IOController ioController;
public static void main(String[] args) {
launch(args);
......@@ -27,9 +29,9 @@ public class Main extends Application {
public static void startNewStage(String name) {
Terrain terrain = new Terrain();
ITerrainController terrainController = new TerrainController(terrain);
IInputOutputController ioController = new IOController(terrain);
IHamsterController hamsterController = new HamsterController(terrain);
TerrainController terrainController = new TerrainController(terrain);
IOController ioController = new IOController(terrain);
HamsterController hamsterController = new HamsterController(terrain);
terrain.setName(name);
Stage newStage = new Stage();
......
......@@ -3,7 +3,7 @@ package controller;
import model.Terrain;
public class HamsterController implements IHamsterController {
public class HamsterController {
private Terrain terrain;
......@@ -31,4 +31,8 @@ public class HamsterController implements IHamsterController {
return terrain.getHamsterCorns();
}
public void start() {
terrain.getHamster().start();
}
}
package controller;
public interface IHamsterController {
public void pickUp();
public void putDown();
public void turnLeft();
public void forward();
public int getHamsterCorns();
}
package controller;
import model.Terrain;
import view.MainViewCreationFX;
public interface IInputOutputController {
void saveFile(String name);
void openFile(String name);
void compile(String name);
MainViewCreationFX getMainViewCreationFX();
void setMainViewCreationFX(MainViewCreationFX mainViewCreationFX);
void setTerrain(Terrain terrain);
}
......@@ -23,7 +23,7 @@ import java.nio.file.Paths;
import static java.lang.System.err;
public class IOController implements IInputOutputController {
public class IOController {
private final String prefix = "public class ";
private final String prefix2 = " extends model.Hamster { public \n";
......@@ -37,7 +37,7 @@ public class IOController implements IInputOutputController {
}
// abgeleitet von https://docs.oracle.com/javase/tutorial/essential/io/file.html
@Override
public void saveFile(String name) {
Path dir = Paths.get("programme");
Path file = Paths.get("programme", name + ".java");
......@@ -57,12 +57,12 @@ public class IOController implements IInputOutputController {
}
@Override
public void openFile(String name) {
Main.startNewStage(name);
}
@Override
public void compile(String name) {
saveFile(name);
ByteArrayOutputStream err = new ByteArrayOutputStream();
......
package controller;
/**
* Created by Stefan Michel on 14.11.17.
*/
public interface ITerrainController {
void addCorn(int row, int col);
void addWall(int row, int col);
void moveHamster(int row, int col);
void deleteTile(int row, int col);
}
......@@ -16,9 +16,9 @@ public class SetFileNameDialogBox {
private boolean breiteIsValid = false;
private boolean hoeheIsValid = false;
private Terrain terrain;
private IInputOutputController ioController;
private IOController ioController;
public SetFileNameDialogBox(Terrain terrain, IInputOutputController ioController) {
public SetFileNameDialogBox(Terrain terrain, IOController ioController) {
this.terrain = terrain;
this.ioController = ioController;
setFileNameDialogBox();
......
......@@ -5,7 +5,7 @@ import model.Terrain;
/**
* Created by Stefan Michel on 13.11.17.
*/
public class TerrainController implements ITerrainController {
public class TerrainController {
private Terrain terrain;
......
......@@ -8,7 +8,7 @@ import view.Invisible;
/**
* Created by Stefan Michel on 23.10.17.
*/
public class Hamster {
public class Hamster extends Thread {
private Terrain terrain;
......@@ -74,4 +74,14 @@ public class Hamster {
public void setTerrain(Terrain terrain) {
this.terrain = terrain;
}
@Invisible
public void run() {
// try {
//
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
this.main();
}
}
......@@ -40,15 +40,15 @@ public class MainViewCreationFX extends VBox {
RadioMenuItem wallMenuItem;
RadioMenuItem deleteMenuItem;
private TerritoriumPanelFX territoriumPanel;
private ITerrainController terrainController;
private IInputOutputController ioController;
private IHamsterController hamsterController;
private TerrainController terrainController;
private IOController ioController;
private HamsterController hamsterController;
private Terrain terrain;
private TextArea textArea;
private ContextMenu contextMenu;
public MainViewCreationFX(Terrain terrain, ITerrainController terrainController, IInputOutputController ioController,
IHamsterController hamsterController) {
public MainViewCreationFX(Terrain terrain, TerrainController terrainController, IOController ioController,
HamsterController hamsterController) {
this.terrainController = terrainController;
this.ioController = ioController;
......@@ -414,6 +414,8 @@ public class MainViewCreationFX extends VBox {
Button pause = new Button(null, new ImageView(new Image("/Pause24.gif")));
Button stopp = new Button(null, new ImageView(new Image("/Stop24.gif")));
start.setOnAction(event -> hamsterController.start());
// Slider
Slider geschwindigkeitSlider = new Slider();
......
package view;
import controller.ITerrainController;
import controller.TerrainController;
import javafx.application.Platform;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
......@@ -20,7 +20,7 @@ import java.util.Observer;
*/
public class TerritoriumPanelFX extends Region implements Observer {
private Terrain terrain;
private ITerrainController terrainController;
private TerrainController terrainController;
private Image hamsterImage;
private List<Image> cornImages;
......@@ -30,7 +30,7 @@ public class TerritoriumPanelFX extends Region implements Observer {
public static final int TILE_SIZE = 32;
public TerritoriumPanelFX(Terrain terrain, ITerrainController terrainController) {
public TerritoriumPanelFX(Terrain terrain, TerrainController terrainController) {
terrain.addObserver(this);
this.terrain = terrain;
this.terrainController = terrainController;
......
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