# HG changeset patch # User meillo@marmaro.de # Date 1182161445 -7200 # Node ID 20c0116dcb97bb59814d84538afe31a50abf7ea7 # Parent 7744082fd6a35c72ef9df00a61a33ba8f42fb2db added files (forgot for last commit diff -r 7744082fd6a3 -r 20c0116dcb97 code/composite-component.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/code/composite-component.java Mon Jun 18 12:10:45 2007 +0200 @@ -0,0 +1,34 @@ + class Composite implements IComponent { + private String id; + private List list = new ArrayList (); + + public Composite(String id) { + this.id = id; + } + + public String toString() { + StringBuilder buf = new StringBuilder(); + buf.append(String.format("(%s:", id)); + + for (IComponent child : list) { + buf.append(" " + child.toString()); + } + buf.append(")"); + + return buf.toString(); + } + + //public List getChildren() + + public Collection getChildren(){ + return list; + } + + public boolean addComponent(IComponent c){ + return list.add(c); + } + + public boolean removeComponent(IComponent c){ + return list.remove(c); + } + } diff -r 7744082fd6a3 -r 20c0116dcb97 code/composite-icomponent.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/code/composite-icomponent.java Mon Jun 18 12:10:45 2007 +0200 @@ -0,0 +1,5 @@ + interface IComponent { + Collection getChildren(); + boolean addComponent(IComponent c); + boolean removeComponent(IComponent c); + } diff -r 7744082fd6a3 -r 20c0116dcb97 code/composite-leaf.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/code/composite-leaf.java Mon Jun 18 12:10:45 2007 +0200 @@ -0,0 +1,25 @@ + class Leaf implements IComponent { + private String id; + + public Leaf(String id) { + this.id = id; + } + + public String toString() { + return this.id; + } + + public Collection getChildren() { + return null; + } + + // false because failed to add + public boolean addComponent(IComponent c) { + return false; + } + + // false because failed to find it for removal + public boolean removeComponent(IComponent c) { + return false; + } + } diff -r 7744082fd6a3 -r 20c0116dcb97 code/composite-main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/code/composite-main.java Mon Jun 18 12:10:45 2007 +0200 @@ -0,0 +1,19 @@ + public class Main { + public static void main(String[] args) { + Composite england = new Composite("England"); + Leaf york = new Leaf("York"); + Leaf london = new Leaf("London"); + england.addComponent(york); + england.addComponent(london); + england.removeComponent(york); + + Composite france = new Composite("France"); + france.addComponent(new Leaf("Paris")); + + Composite europe = new Composite("Europe"); + europe.addComponent(england); + europe.addComponent(france); + + System.out.println(europe.toString()); + } + } diff -r 7744082fd6a3 -r 20c0116dcb97 composite.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/composite.tex Mon Jun 18 12:10:45 2007 +0200 @@ -0,0 +1,143 @@ +% @file +% @brief Referat DesignPattern `Composite' +% @author dimitar dimitrov +% @since 2007-06-18 + + +\documentclass{beamer} + + + \usepackage[T1]{fontenc} + \usepackage[latin1]{inputenc} + \usepackage{ngerman} + \usepackage{graphicx} + \usepackage[automark]{scrpage2} + \usepackage{listings} + \input{Style01} + + + +\begin{document} + + +\title{Design Pattern ``Composite''} +\date{\today} + +\author{Dimitar Dimitrov} + +%\titlegraphic{\includegraphics[width=3cm]{Pics/Maka-Logo.png}} + +\frame{ + \titlepage +} + + + + + +\section[Outline]{} +\frame{ + Dauer der Präsentation: etwa 10 Minuten + \vspace{2ex} + + \tableofcontents +} + + + + +\section{Definition} + +\frame{ \frametitle{Definition} + + \begin{block}{} + \end{block} + +} + + +\section{Motivation} + +\frame{ \frametitle{Motivation} + + \begin{block}{} + \end{block} + +} + + +\section{Wann verwenden?} +\frame{ \frametitle{Wann verwenden?} + + \begin{block}{} + \end{block} + +} + + + +\section{Struktur} + +\frame{ \frametitle{UML-Diagramm des Composite-Pattern} + \centerline{ \includegraphics[width=20em]{pics/composite_big.png} } +} + + + + + +\section{Java-Beispiel} +\frame{ \frametitle{class Main, interface IComponent} + + {\tiny + \lstinputlisting[language=java]{code/composite-main.java} + \lstinputlisting[language=java]{code/composite-icomponent.java} + } + +} + + +\frame{ \frametitle{class Composite} + + {\tiny + \lstinputlisting[language=java]{code/composite-composite.java} + } + +} + + +\frame{ \frametitle{class Leaf} + + {\tiny + \lstinputlisting[language=java]{code/composite-leaf.java} + } + +} + + + + +\section{Zusammenfassung} +\frame{ %\frametitle{Zusammenfassend} + \begin{block}{Zusammenfassung} + \begin{itemize} + \item + \item + \item + \end{itemize} + \end{block} + + \pause + + \begin{block}{Fazit} + \begin{itemize} + \item + \item + \item + \end{itemize} + \end{block} +} + + + +\end{document} diff -r 7744082fd6a3 -r 20c0116dcb97 pics/composite.png Binary file pics/composite.png has changed diff -r 7744082fd6a3 -r 20c0116dcb97 pics/composite_big.png Binary file pics/composite_big.png has changed diff -r 7744082fd6a3 -r 20c0116dcb97 pics/observer_big.png Binary file pics/observer_big.png has changed