From 2b5d791aee37ea7473aa1d4f96b6eaa1e5494ad8 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Sun, 8 May 2022 22:37:44 +0200 Subject: [PATCH] changed Method toString to printBand and show "lesekopf" with different Color. Delete Main.java --- src/Main.java | 6 ------ src/TM.java | 17 ++++++++++------- 2 files changed, 10 insertions(+), 13 deletions(-) delete mode 100644 src/Main.java diff --git a/src/Main.java b/src/Main.java deleted file mode 100644 index 1ef8157..0000000 --- a/src/Main.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Main { - - public static void main(String[] args) { - - } -} diff --git a/src/TM.java b/src/TM.java index fb70a9e..9026ff0 100644 --- a/src/TM.java +++ b/src/TM.java @@ -35,7 +35,7 @@ public class TM { if(!onlyResult){ System.out.println("Step: "+numberOfSteps); System.out.println("Aktueller zustand: Q" + aktuellerZustand); - System.out.println(this); + printBand(); } } catch (TmException e) { e.printStackTrace(); @@ -45,7 +45,7 @@ public class TM { System.out.println("Finished:"); System.out.println("Zustand: Q" + aktuellerZustand); System.out.println("Step: "+numberOfSteps); - System.out.println(this); + printBand(); } private void calcOneStep() throws TmException { @@ -77,12 +77,15 @@ public class TM { aktuellerZustand = str[2].length(); } - public String toString() { - StringBuilder stringBuilder = new StringBuilder(); - for (Character c : band) { - stringBuilder.append(c); + public void printBand() { + for(int i = 0; i < band.size(); i++) { + if(i == leseKopf){ + System.out.print("\u001B[31m" + band.get(i) + "\u001B[0m"); + } else { + System.out.print(band.get(i)); + } } - return stringBuilder.toString(); + System.out.println(); } private boolean checkWin() {