Browse Source

Added deactivation for clearConsole() method because it would throw warnings otherwise.

feature-app
Nick Stolbov 3 years ago
parent
commit
71bce709ab
  1. 1
      src/main/java/Application/App.java
  2. 10
      src/main/java/Application/Cli.java
  3. 2
      src/test/java/Application/AppTest.java

1
src/main/java/Application/App.java

@ -30,6 +30,7 @@ public class App {
return;
} else {
ttt.update(input);
cli.clearConsole();
ttt.print(cli);
}
}

10
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;
}
}

2
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());

Loading…
Cancel
Save