You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
919 B
42 lines
919 B
package de.edu.hsfulda.ciip.tdd;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.PrintStream;
|
|
import java.util.List;
|
|
|
|
public class TannenbaumUi {
|
|
|
|
public static final String TREE_SIZE_PROMPT = "enter tree size:";
|
|
private InputStream input;
|
|
private PrintStream output;
|
|
|
|
public TannenbaumUi(InputStream input, PrintStream output) {
|
|
this.input = input;
|
|
this.output = output;
|
|
// TODO Auto-generated constructor stub
|
|
}
|
|
|
|
public int getTreeSize() {
|
|
output.println("enter tree size:");
|
|
try {
|
|
int available = input.available();
|
|
int treesize = 0;
|
|
for (int i = 0; i < available; i++) {
|
|
treesize *= 10;
|
|
treesize += input.read() - '0';
|
|
}
|
|
return treesize;
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
public void print(List<String> messageLines) {
|
|
for (String line : messageLines) {
|
|
output.println(line);
|
|
}
|
|
}
|
|
|
|
}
|