From 71bce709ab5ccb62f279d706c7cfbd246205a274 Mon Sep 17 00:00:00 2001 From: Nick Stolbov Date: Thu, 27 Jan 2022 20:54:41 +0100 Subject: [PATCH] Added deactivation for clearConsole() method because it would throw warnings otherwise. --- src/main/java/Application/App.java | 1 + src/main/java/Application/Cli.java | 10 ++++++++++ src/test/java/Application/AppTest.java | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/main/java/Application/App.java b/src/main/java/Application/App.java index da2f9bd..86c4865 100644 --- a/src/main/java/Application/App.java +++ b/src/main/java/Application/App.java @@ -30,6 +30,7 @@ public class App { return; } else { ttt.update(input); + cli.clearConsole(); ttt.print(cli); } } diff --git a/src/main/java/Application/Cli.java b/src/main/java/Application/Cli.java index 2b93962..0defedf 100644 --- a/src/main/java/Application/Cli.java +++ b/src/main/java/Application/Cli.java @@ -6,6 +6,8 @@ import java.util.Scanner; public class Cli { + private boolean isClearConsoleActive = true; + private PrintStream printStream; private InputStream inputStream; private Scanner scanner; @@ -14,6 +16,7 @@ public class Cli { this.printStream = printStream; this.inputStream = inputStream; this.scanner = new Scanner(inputStream); + isClearConsoleActive = true; } public PrintStream getPrintStream() { @@ -25,6 +28,8 @@ public class Cli { } public void clearConsole(){ + if(!isClearConsoleActive) + return; try{ String operatingSystem = System.getProperty("os.name");//Check the current operating system @@ -42,4 +47,9 @@ public class Cli { this.getPrintStream().println(e); } } + + public void setClearConsoleActive(boolean clearConsoleActive) { + isClearConsoleActive = clearConsoleActive; + } + } diff --git a/src/test/java/Application/AppTest.java b/src/test/java/Application/AppTest.java index 4813ea6..c3b25e2 100644 --- a/src/test/java/Application/AppTest.java +++ b/src/test/java/Application/AppTest.java @@ -22,6 +22,7 @@ class AppTest { @BeforeEach void setUp() { cli = new Cli(new PrintStream(outContent), inContent); + cli.setClearConsoleActive(false); app = new App(cli); } @@ -34,6 +35,7 @@ class AppTest { void stop() { ByteArrayInputStream input = new ByteArrayInputStream("1\n2\nq\n".getBytes()); cli = new Cli(new PrintStream(outContent), input); + cli.setClearConsoleActive(false); app = new App(cli); app.start(); assertFalse(app.isRunning());