private void runDemo() throws IOException { Report farmCommodityReport = new Report(); farmCommodityReport.showLine("Farm Report"); farmCommodityReport.newline(); farmCommodityReport.showLine("Commodities:"); farmCommodityReport.newline(); farmCommodityReport.showLines(commodityNames()); farmCommodityReport.newline(); farmCommodityReport.showLine("Trends:"); farmCommodityReport.newline(); farmCommodityReport.showLine("Corn up $0.05"); farmCommodityReport.showLine("Soybeans down -$0.20"); farmCommodityReport.showLine("Wheat unchanged"); farmCommodityReport.writeAndView("FarmReport.txt"); }
private void runDemoWithMethodCascading() throws IOException { Report farmCommodityReport = new Report(); farmCommodityReport .showLine("Farm Report") .newline() .showLine("Commodities:") .newline() .showLines(commodityNames()) .newline() .showLine("Trends:") .newline() .showLine("Corn up $0.05") .showLine("Soybeans down -$0.20") .showLine("Wheat unchanged") .writeAndView("FarmReport.txt"); }
private void runDemo() throws IOException {
Report farmCommodityReport = new Report();
farmCommodityReport.showLine("Farm Report");
farmCommodityReport.newline();
farmCommodityReport.showLine("Commodities:");
farmCommodityReport.newline();
farmCommodityReport.showLines(commodityNames());
farmCommodityReport.newline();
farmCommodityReport.showLine("Trends:");
farmCommodityReport.newline();
farmCommodityReport.showLine("Corn up $0.05");
farmCommodityReport.showLine("Soybeans down -$0.20");
farmCommodityReport.showLine("Wheat unchanged");
farmCommodityReport.writeAndView("FarmReport.txt");
}
private void runDemoWithMethodCascading() throws IOException {
Report farmCommodityReport = new Report();
farmCommodityReport
.showLine("Farm Report")
.newline()
.showLine("Commodities:")
.newline()
.showLines(commodityNames())
.newline()
.showLine("Trends:")
.newline()
.showLine("Corn up $0.05")
.showLine("Soybeans down -$0.20")
.showLine("Wheat unchanged")
.writeAndView("FarmReport.txt");
}
public class Report { private String contents; public Report show(Object o) { basicShow(o); return this; } public Report showLine(Object o) { basicShow(o); newline(); return this; } public Report showLines(List<?> lines) { for (Object each: lines) showLine(each); return this; }
public class Report { private String contents; public1Report copyReport() { return2new Report(this); }