public class Hanoi { //Instanzvariablen private final int size = 3; private int [][] field; //Konstruktor Hanoi(){ field = new int [size][size]; } //Methoden //@param int choice, 1-size valid //output: Hanoi private Hanoi left(int choice){ if (!isDirectionVaild(true, choice)){ System.out.println("Geht nich"); } } //ValidTower - ist auf dem Turm eine scheibe private boolean isTowerValid(int check){ if(!isChoiceValid(check)){return false;} for (int i = 0; i <= size; i++){ if (field[check][i] != 0){ return true; } } return false; } private boolean isChoiceValid(int choice){ return choice > 0 && choice <= size; } private int highestSlice (int tower){ int res = 0; for (int i = 0; i < size; i++){ if(field[tower][i] != 0){ res = field[tower][i]; } } return res; } // private boolean isDirectionVaild(boolean direct, int tower){ if(!isTowerValid(tower)){return false;} int varli = tower == 0 ? 2 : tower-1; int varre = tower == 2 ? 0 : tower+1; //direct = true = links if (direct){ if (highestSlice(tower) < highestSlice(varli)){return true;} } if (!direct){ if (highestSlice(tower) < highestSlice(varre)){return true;} } return false; } }