changeset 7:20c0116dcb97

added files (forgot for last commit
author meillo@marmaro.de
date Mon, 18 Jun 2007 12:10:45 +0200
parents 7744082fd6a3
children c9e5dcd79aae
files code/composite-component.java code/composite-icomponent.java code/composite-leaf.java code/composite-main.java composite.tex pics/composite.png pics/composite_big.png pics/observer_big.png
diffstat 8 files changed, 226 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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<IComponent> list = new ArrayList<IComponent> ();
+
+            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<IComponent> getChildren()
+
+            public Collection getChildren(){
+                    return list;
+            }
+
+            public boolean addComponent(IComponent c){
+                    return list.add(c);
+            }
+
+            public boolean removeComponent(IComponent c){
+                    return list.remove(c);
+            }
+    }
--- /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);
+    }
--- /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;
+            }
+    }
--- /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());
+            }
+    }
--- /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}
Binary file pics/composite.png has changed
Binary file pics/composite_big.png has changed
Binary file pics/observer_big.png has changed