Podsumowanie wzorców projektowych GoF
Podsumowanie wzorców projektowych GoF
Podsumowanie wzorców projektowych GoF
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
public class DvdTitleExpression extends DvdAbstractExpression {public String interpret(DvdInterpreterContextdvdInterpreterContext) {ArrayList titles = dvdInterpreterContext.getAllTitles();ListIterator titlesIterator = titles.listIterator();StringBuffer titleBuffer = new StringBuffer("");boolean first = true;while (titlesIterator.hasNext()) {if (!first) {titleBuffer.append(", ");} else {first = false;}titleBuffer.append((String)titlesIterator.next());}return titleBuffer.toString();}}Wyjcie na konsoli:interpreting show actor: Query Result: Ethan Hawke, Denzel Washingtoninterpreting show actor for title : Query Result: Ethan Hawke, Denzel Washingtoninterpreting show title: Query Result: Caddy Shack, Training Day, Hamletinterpreting show title for actor : Query Result: Hamlet, Training Day, Caddy Shack88