12.07.2015 Views

Podsumowanie wzorców projektowych GoF

Podsumowanie wzorców projektowych GoF

Podsumowanie wzorców projektowych GoF

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}}} else {System.out.println("teaBag2 not successfully removed from tinOfTeaBags");}System.out.println("The tinOfTeaBags now has " +tinOfTeaBags.countTeaBags() +" tea bags in it.");Klasy wzorca:TeaBagspackage pk.dydakt.to.dp.s.gof.composite;import java.util.LinkedList;import java.util.ListIterator;public abstract class TeaBags {LinkedList teaBagList;TeaBags parent;String name;public abstract int countTeaBags();public abstract boolean add(TeaBags teaBagsToAdd);public abstract boolean remove(TeaBags teaBagsToRemove);public abstract ListIterator createListIterator();public void setParent(TeaBags parentIn) {parent = parentIn;}public TeaBags getParent() {return parent;}}public void setName(String nameIn) {name = nameIn;}public String getName() {return name;}OneTeaBagpackage pk.dydakt.to.dp.s.gof.composite;import java.util.ListIterator;public class OneTeaBag extends TeaBags {public OneTeaBag(String nameIn) {this.setName(nameIn);}public int countTeaBags() {return 1;}public boolean add(TeaBags teaBagsToAdd) {return false;}29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!