HI. Ich bräuchte mal Hilfe.
Ich habe einen Code, was mir Outputs in der Konsole liefert. Ich will es aber grafisch dargestellt haben. Wie mache ich es vom Prinzip her?
Ist das der richtige Ansatz?
Ich habe einen Code, was mir Outputs in der Konsole liefert. Ich will es aber grafisch dargestellt haben. Wie mache ich es vom Prinzip her?
Code:
public class TuermeVonHanoi {
static void ziehe_scheibe(int nummer, String von, String nach) {
System.out.println("Scheibe " + nummer + " wird von " + von +
" nach " + nach + " verschoben ");
}
static void hanoi(int N, String platz1, String hilfsplatz, String platz2)
{
if (N == 1) {
ziehe_scheibe(N, platz1, platz2);
} else {
hanoi(N-1, platz1, platz2, hilfsplatz);
ziehe_scheibe(N, platz1, platz2);
hanoi(N-1, hilfsplatz, platz1, platz2);
}
}
public static void main(String[] args) {
hanoi(4, "A", "B", "C");
}
}
Ist das der richtige Ansatz?
Code:
public void start(Stage primaryStage) throws Exception {
root = new Group();
Scene scene = new Scene(root, 600, 400);
primaryStage.setScene(scene);
primaryStage.setTitle("Hanoi");
Rectangle panel = new Rectangle(600, 400, Color.WHITESMOKE);
root.getChildren().add(panel);
primaryStage.show();