/** * OutputInterface implementation using for loops * * @author Alexander Schaap * */ public class Output extends OutputAbstract { @Override public void print() { String result = ""; for (int ln = 0; ln < sls.length(); ln++) { StorageInterface>> line = sls.get(ln); for (int i = 0; i < line.length(); i++) { StorageInterface> shift = line.get(i); for (int j = 0; j < shift.length(); j++) { WordInterface word = shift.get(j); result += word + " "; } result = result.substring(0, result.length() - 1) + ", "; } result = result.substring(0, result.length() - 2) + '\n'; } this.result += result; result = result.isEmpty() ? "" : result.substring(0, result.length() - 1); System.out.println(result); } }