the solution is not a real wrapper in my eyes.
shouldnt it be like this?:
package de.codegym.task.task19.task1911;
/*
Reader-Wrapper
*/
import java.io.PrintStream;
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) {
PrintStream original = System.out;
System.setOut(new ReaderWrapper(original));
testString.printSomething();
System.setOut(original);
}
public static class ReaderWrapper extends PrintStream {
PrintStream original;
public ReaderWrapper(PrintStream original){
super(original);
this.original=original;
}
public void println(String s){
original.println(s.toUpperCase());
}
}
public static class TestString {
public void printSomething() {
System.out.println("This is text for testing");
}
}
}
here is the learning:
examplepackage de.codegym.task.task19.task1911;
/*
Reader-Wrapper
*/
import java.io.PrintStream;
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) {
PrintStream original = System.out;
System.setOut(new ReaderWrapper(original));
TestString ts = new TestString();
ts.printSomething();
System.setOut(original);
}
public static class ReaderWrapper extends PrintStream {
PrintStream original;
public ReaderWrapper(PrintStream original){
super(original);
this.original=original;
}
public void println(String s){
original.println(s.toUpperCase());
}
}
public static class TestString {
public void printSomething() {
System.out.println("This is text for testing");
}
}
}