From 5979e2805be66a82d0bda13086cd6a47437a4e8d Mon Sep 17 00:00:00 2001 From: leobr Date: Sun, 8 May 2022 22:32:51 +0200 Subject: [PATCH] =?UTF-8?q?Moditrennung=20hinzugef=C3=BCgt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TM.java | 13 +++++++------ src/TestClass.java | 12 +++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/TM.java b/src/TM.java index b326364..fb70a9e 100644 --- a/src/TM.java +++ b/src/TM.java @@ -27,15 +27,16 @@ public class TM { } - public void start() { - while (!checkWin()) { + public void start(boolean onlyResult) { + while (!checkWin() ) { try { calcOneStep(); appendToBand(); - - System.out.println("Step: "+numberOfSteps); - System.out.println("Aktueller zustand: Q" + aktuellerZustand); - System.out.println(this); + if(!onlyResult){ + System.out.println("Step: "+numberOfSteps); + System.out.println("Aktueller zustand: Q" + aktuellerZustand); + System.out.println(this); + } } catch (TmException e) { e.printStackTrace(); break; diff --git a/src/TestClass.java b/src/TestClass.java index 43f1389..a6116a7 100644 --- a/src/TestClass.java +++ b/src/TestClass.java @@ -5,18 +5,24 @@ public class TestClass { TM turing; - + /** + * Test von Turingmaschine Multiplikation 2x3 nur mit Ausgabe vom Resultat + */ @Test void check() { turing = new TM("101010001000100110100100000000000010001001100010010000100100110001010001010011000010001000001001011000010010000010010110000101000010100110000010000100000100001001100000100100000010010011000001010000010000100110000001000100000001010110000001010000001010011000000010010000000010010110000000101000000010101100000000100001000000001000010110000000010010000000001001001100000000101000001000010011000000000100001000000000101001100000000010010000000000100101100000000001001000000000001001011000000000010100000000001010110000000000010001010001001100000000000101000000000001010110000000000001001001000100110000000000001010000000000001000100", "001000"); - turing.start(); + turing.start(true); } + + /** + * Test von Turingmaschine Multiplikation 3x4 mit Step by Step Ausgabe. + */ @Test void check2() { turing = new TM("101010001000100110100100000000000010001001100010010000100100110001010001010011000010001000001001011000010010000010010110000101000010100110000010000100000100001001100000100100000010010011000001010000010000100110000001000100000001010110000001010000001010011000000010010000000010010110000000101000000010101100000000100001000000001000010110000000010010000000001001001100000000101000001000010011000000000100001000000000101001100000000010010000000000100101100000000001001000000000001001011000000000010100000000001010110000000000010001010001001100000000000101000000000001010110000000000001001001000100110000000000001010000000000001000100", "0001000"); - turing.start(); + turing.start(false); } }