aboutsummaryrefslogtreecommitdiff
path: root/Info/10/2/Polymorphismus/slides.tex
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-04-25 22:56:27 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-04-25 22:56:27 +0200
commitc8af53de24e3e7535726138cb5ca8caeaf6d8cb1 (patch)
tree0e3173dfb3606d8173b43d912156b6da8c4b46c1 /Info/10/2/Polymorphismus/slides.tex
parent1b2dd19ec6a75e1fe0b6275def842b6753a38f8f (diff)
downloadunterricht-c8af53de24e3e7535726138cb5ca8caeaf6d8cb1.tar.gz
unterricht-c8af53de24e3e7535726138cb5ca8caeaf6d8cb1.zip
add my polymorphism slides
Diffstat (limited to 'Info/10/2/Polymorphismus/slides.tex')
-rw-r--r--Info/10/2/Polymorphismus/slides.tex856
1 files changed, 856 insertions, 0 deletions
diff --git a/Info/10/2/Polymorphismus/slides.tex b/Info/10/2/Polymorphismus/slides.tex
new file mode 100644
index 00000000..17ffe186
--- /dev/null
+++ b/Info/10/2/Polymorphismus/slides.tex
@@ -0,0 +1,856 @@
+% Options for packages loaded elsewhere
+\PassOptionsToPackage{unicode}{hyperref}
+\PassOptionsToPackage{hyphens}{url}
+%
+\documentclass[
+ ignorenonframetext,
+ aspectratio=169,
+]{beamer}
+\usepackage{pgfpages}
+\setbeamertemplate{caption}[numbered]
+\setbeamertemplate{caption label separator}{: }
+\setbeamercolor{caption name}{fg=normal text.fg}
+\beamertemplatenavigationsymbolsempty
+% Prevent slide breaks in the middle of a paragraph
+\widowpenalties 1 10000
+\raggedbottom
+\setbeamertemplate{part page}{
+ \centering
+ \begin{beamercolorbox}[sep=16pt,center]{part title}
+ \usebeamerfont{part title}\insertpart\par
+ \end{beamercolorbox}
+}
+\setbeamertemplate{section page}{
+ \centering
+ \begin{beamercolorbox}[sep=12pt,center]{part title}
+ \usebeamerfont{section title}\insertsection\par
+ \end{beamercolorbox}
+}
+\setbeamertemplate{subsection page}{
+ \centering
+ \begin{beamercolorbox}[sep=8pt,center]{part title}
+ \usebeamerfont{subsection title}\insertsubsection\par
+ \end{beamercolorbox}
+}
+\AtBeginPart{
+ \frame{\partpage}
+}
+\AtBeginSection{
+ \ifbibliography
+ \else
+ \frame{\sectionpage}
+ \fi
+}
+\AtBeginSubsection{
+ \frame{\subsectionpage}
+}
+\usepackage{amsmath,amssymb}
+\usepackage{iftex}
+\ifPDFTeX
+ \usepackage[T1]{fontenc}
+ \usepackage[utf8]{inputenc}
+ \usepackage{textcomp} % provide euro and other symbols
+\else % if luatex or xetex
+ \usepackage{unicode-math} % this also loads fontspec
+ \defaultfontfeatures{Scale=MatchLowercase}
+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
+\fi
+\usepackage{lmodern}
+\usetheme[]{Rochester}
+\ifPDFTeX\else
+ % xetex/luatex font selection
+\fi
+% Use upquote if available, for straight quotes in verbatim environments
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+\IfFileExists{microtype.sty}{% use microtype if available
+ \usepackage[]{microtype}
+ \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
+}{}
+\makeatletter
+\@ifundefined{KOMAClassName}{% if non-KOMA class
+ \IfFileExists{parskip.sty}{%
+ \usepackage{parskip}
+ }{% else
+ \setlength{\parindent}{0pt}
+ \setlength{\parskip}{6pt plus 2pt minus 1pt}}
+}{% if KOMA class
+ \KOMAoptions{parskip=half}}
+\makeatother
+\usepackage{xcolor}
+\newif\ifbibliography
+\usepackage{graphicx}
+\makeatletter
+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
+\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
+\makeatother
+% Scale images if necessary, so that they will not overflow the page
+% margins by default, and it is still possible to overwrite the defaults
+% using explicit options in \includegraphics[width, height, ...]{}
+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
+% Set default figure placement to htbp
+\makeatletter
+\def\fps@figure{htbp}
+\makeatother
+\setlength{\emergencystretch}{3em} % prevent overfull lines
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
+\usepackage[school]{pgf-umlcd}
+\usepackage{unicode-math}
+\usepackage{pifont}
+\usepackage{tikz}
+\usepackage{minted}
+\usetikzlibrary{calc}
+\pgfdeclareradialshading[droplet color]{droplet}{\pgfqpoint{-10bp}{-10bp}}{color(0bp)=(droplet color!50!white); color(9bp)=(droplet color!75!white); color(18bp)=(droplet color!85!black); color(25bp)=(droplet color); color(50bp)=(droplet color!50!white)}
+\colorlet{droplet color}{blue!50!cyan}
+\ifLuaTeX
+ \usepackage{selnolig} % disable illegal ligatures
+\fi
+\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
+\urlstyle{same}
+\hypersetup{
+ pdfauthor={Florian Fischer},
+ hidelinks,
+ pdfcreator={LaTeX via pandoc}}
+
+\author{Florian Fischer}
+\date{}
+
+\begin{document}
+
+\begin{frame}[fragile]{Lessons learned?}
+\protect\hypertarget{lessons-learned}{}
+\begin{columns}[T]
+\begin{column}{0.48\textwidth}
+\includegraphics{../Datenkapselung/img/Computer-hacker.jpg}
+\end{column}
+
+\begin{column}{0.48\textwidth}
+\includegraphics{../Datenkapselung/img/Bank.png}
+\end{column}
+\end{columns}
+\end{frame}
+
+\begin{frame}[fragile]{Erkenntnis}
+\protect\hypertarget{erkenntnis}{}
+Auch in Software müssen, wie in der Realität, Zugriff fest geregelt
+sein.
+
+\vspace{1cm}
+\pause
+
+\begin{block}{Dazu bieten Java die Zugrifsmodifikatoren}
+\protect\hypertarget{dazu-bieten-java-die-zugrifsmodifikatoren}{}
+\begin{itemize}
+\tightlist
+\item
+ \mintinline[]{java}{private} - Nur Zugriff innerhalb der selben Klasse
+\item
+ \mintinline[]{java}{public} - Uneingeschränkter Zugriff
+\end{itemize}
+
+\pause
+
+\begin{tikzpicture}[overlay, remember picture]
+ \node[rotate=-20,scale=3] at (12, 3) {\Huge \color{red} \textbf{!}};
+\end{tikzpicture}
+\end{block}
+\end{frame}
+
+\begin{frame}[fragile]{Grundsatz der Datenkapselung}
+\protect\hypertarget{grundsatz-der-datenkapselung}{}
+Zwei Aspekte sind wichtig:
+
+\vspace{0.5cm}
+
+\begin{enumerate}[<+->]
+\tightlist
+\item
+ \textbf{Nur} Objekt selbst sollte Zugriff auf seine Daten haben
+\item
+ \textbf{Benötigter} Zugriff von außen soll über von dem Objekt
+ bereitgestellte Methoden erfolgen
+\end{enumerate}
+
+\begin{tikzpicture}[overlay, remember picture]
+ \only<3> {
+ \node[rotate=-30,scale=3] at (12, 3) {\Huge \color{red} \textbf{!}};
+ }
+\end{tikzpicture}
+\end{frame}
+
+\begin{frame}[t,fragile]{Datenkapselung Anwendung}
+\protect\hypertarget{datenkapselung-anwendung}{}
+\begin{minted}[linenos,autogobble]{java}
+class Bankkonto {
+ public double kontostand;
+ private kontonummer;
+
+ public gibBetrag() { return kontostand; }
+ private gibKontoNummer() { return kontonummer; }
+}
+\end{minted}
+\end{frame}
+
+\begin{frame}[t,fragile]{Datenkapselung Anwendung}
+\protect\hypertarget{datenkapselung-anwendung-1}{}
+\begin{minted}[linenos,highlightlines={2},autogobble]{java}
+class Bankkonto {
+ public double kontostand;
+ private kontonummer;
+
+ public gibBetrag() { return kontostand; }
+ private gibKontoNummer() { return kontonummer; }
+}
+\end{minted}
+\end{frame}
+
+\begin{frame}[t,fragile]{Datenkapselung Anwendung}
+\protect\hypertarget{datenkapselung-anwendung-2}{}
+\begin{minted}[linenos,highlightlines={2},autogobble]{java}
+class Bankkonto {
+ public double kontostand;
+ private kontonummer;
+
+ public gibBetrag() { return kontostand; }
+ private gibKontoNummer() { return kontonummer; }
+}
+\end{minted}
+
+\vspace{1cm}
+
+\begin{itemize}
+\tightlist
+\item
+ Zeile 2: Uneingeschränkter Zugriff
+\end{itemize}
+\end{frame}
+
+\begin{frame}[t,fragile]{Datenkapselung Anwendung}
+\protect\hypertarget{datenkapselung-anwendung-3}{}
+\begin{minted}[linenos,highlightlines={2,6},autogobble]{java}
+class Bankkonto {
+ public double kontostand;
+ private kontonummer;
+
+ public gibBetrag() { return kontostand; }
+ private gibKontoNummer() { return kontonummer; }
+}
+\end{minted}
+
+\vspace{1cm}
+
+\begin{itemize}
+\tightlist
+\item
+ Zeile 2: Uneingeschränkter Zugriff
+\end{itemize}
+\end{frame}
+
+\begin{frame}[t,fragile]{Datenkapselung Anwendung}
+\protect\hypertarget{datenkapselung-anwendung-4}{}
+\begin{minted}[linenos,highlightlines={2,6},autogobble]{java}
+class Bankkonto {
+ public double kontostand;
+ private kontonummer;
+
+ public gibBetrag() { return kontostand; }
+ private gibKontoNummer() { return kontonummer; }
+}
+\end{minted}
+
+\vspace{1cm}
+
+\begin{itemize}
+\tightlist
+\item
+ Zeile 2: Uneingeschränkter Zugriff
+\item
+ Zeile 6: Kein Zugriff von außen möglich
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]{Lessons learned!}
+\protect\hypertarget{lessons-learned-1}{}
+\begin{columns}[T]
+\begin{column}{0.48\textwidth}
+\includegraphics{../Datenkapselung/img/Computer-hacker.jpg}
+\end{column}
+
+\begin{column}{0.48\textwidth}
+\includegraphics{../Datenkapselung/img/Bank.png}
+\end{column}
+\end{columns}
+
+\begin{tikzpicture}[
+ overlay,
+ remember picture,
+ raindrop/.pic={
+ code={\tikzset{scale=1/10}
+ \shade [shading=droplet]
+ (0,0) .. controls ++(0,-1) and ++(0,1) .. (1,-2)
+ arc (360:180:1)
+ .. controls ++(0,1) and ++(0,-1) .. (0,0) -- cycle;
+ }
+}]
+ \only<2-> {
+ \path (3.65,3) pic {raindrop};
+ \path (3.85,2.8) pic {raindrop};
+ }
+
+ \draw[transform canvas={shift={(8,1)}}, scale=2, line width=2pt] (3ex,2.5ex) -- (1.5ex,3ex) -- (0ex,2.5ex) to [out=-90, in=165] (1.5ex,0ex) to [out=15, in=-90] cycle (1.5ex,1.5ex) node {\Large \ding{51}};
+\end{tikzpicture}
+\end{frame}
+
+\begin{frame}[fragile]{Wdh. Vererbung - Auto}
+\protect\hypertarget{wdh.-vererbung---auto}{}
+\hfill\break{\centering\includegraphics[width=\textwidth,height=0.85\textheight]{img/Copyrighted/car_explosion.png}\par}
+\end{frame}
+
+\begin{frame}[fragile]{Wdh. Vererbung - Auto}
+\protect\hypertarget{wdh.-vererbung---auto-1}{}
+\begin{tikzpicture}
+ \begin{class}[text width=3cm]{AUTO}{0,0}
+ \attribute{...}
+ \operation{...}
+ \end{class}
+
+ \begin{class}[text width=3cm]{BAUTEIL}{9,0}
+ \attribute{...}
+ \operation{...}
+ \end{class}
+
+ \association{AUTO}{1}{besteht aus >}{BAUTEIL}{< verbaut in}{n}
+\end{tikzpicture}
+
+\vspace{1cm}
+
+Hilft uns diese Modellierung beim Konstruieren eines Autos?
+\end{frame}
+
+\begin{frame}[fragile]{Wdh. Vererbung Spezialisierung - Auto}
+\protect\hypertarget{wdh.-vererbung-spezialisierung---auto}{}
+\begin{tikzpicture}
+ \begin{class}[text width=3cm]{AUTO}{0, 2.5}
+ \attribute{...}
+ \operation{...}
+ \end{class}
+
+ \begin{class}[text width=3cm]{BAUTEIL}{5, 2.5}
+ \attribute{...}
+ \operation{...}
+ \end{class}
+
+ \association{AUTO}{1}{}{BAUTEIL}{n}{}
+
+ \begin{class}[text width=4cm]{Motor}{10, 0}
+ \inherit{BAUTEIL}
+ \attribute{...}
+ \operation{...}
+ \end{class}
+
+ \begin{class}[text width=4cm]{Felge}{10, 2.5}
+ \inherit{BAUTEIL}
+ \attribute{...}
+ \operation{...}
+ \end{class}
+
+ \begin{class}[text width=4cm]{Windschutzscheibe}{10, 5}
+ \inherit{BAUTEIL}
+ \attribute{...}
+ \operation{...}
+ \end{class}
+\end{tikzpicture}
+\end{frame}
+
+\begin{frame}[t,fragile]{Wdh. Vererbung in Java}
+\protect\hypertarget{wdh.-vererbung-in-java}{}
+Das Java Schlüsselwort \ldots{}
+\end{frame}
+
+\begin{frame}[t,fragile]{Wdh. Vererbung in Java}
+\protect\hypertarget{wdh.-vererbung-in-java-1}{}
+Das Java Schlüsselwort \mintinline[]{java}{extends} drückt eine
+Vererbungsbeziehung zwischen zwei Klassen aus.
+
+\vspace{0.5cm}
+
+\pause
+
+\begin{block}{Syntax der Klassendefinition}
+\protect\hypertarget{syntax-der-klassendefinition}{}
+\mintinline[]{java}|class Unterklasse extends Oberklasse {...}|
+\end{block}
+
+\vspace{0.5cm}
+
+\pause
+
+Die Unterklasse erbt alle Methoden und Attribute der Oberklasse.\\
+Man spricht: ``Eine Felge \emph{ist} ein Bauteil''.
+
+\pause
+
+\begin{tikzpicture}[overlay, remember picture]
+ \node[rotate=-30,scale=3] at (12, 3) {\Huge \color{red} \textbf{!}};
+\end{tikzpicture}
+\end{frame}
+
+\begin{frame}[fragile]{Wdh. Vererbung in Java}
+\protect\hypertarget{wdh.-vererbung-in-java-2}{}
+\begin{columns}[T]
+\begin{column}{0.4\textwidth}
+\begin{minted}[autogobble]{java}
+class Oberklasse {
+ private int zahl;
+
+ public void Oberklasse(int n)
+ {
+ zahl = n;
+ }
+
+ public void gibZahl() {
+ return zahl;
+ }
+}
+\end{minted}
+\end{column}
+
+\begin{column}{0.5\textwidth}
+\begin{minted}[autogobble]{java}
+class Unterklasse extends Oberklasse {
+ public void Unterklasse(int n) {
+ // Oberklasse Initialisierung?
+ }
+}
+\end{minted}
+\end{column}
+\end{columns}
+\end{frame}
+
+\begin{frame}[fragile]{Wdh. Vererbung in Java}
+\protect\hypertarget{wdh.-vererbung-in-java-3}{}
+\begin{columns}[T]
+\begin{column}{0.4\textwidth}
+\begin{minted}[autogobble]{java}
+class Oberklasse {
+ private int zahl;
+
+ public void Oberklasse(int n)
+ {
+ zahl = n;
+ }
+
+ public void gibZahl() {
+ return zahl;
+ }
+}
+\end{minted}
+\end{column}
+
+\begin{column}{0.5\textwidth}
+\begin{minted}[highlightlines={3},autogobble]{java}
+class Unterklasse extends Oberklasse {
+ public void Unterklasse(int n) {
+ super(n);
+ }
+}
+\end{minted}
+\end{column}
+\end{columns}
+\end{frame}
+
+\begin{frame}[t,fragile]{Wdh. Vererbung in Java}
+\protect\hypertarget{wdh.-vererbung-in-java-4}{}
+\vspace{1cm}
+
+Die Oberklasse ist über das Java Schlüsselwort \ldots{} benutzbar.
+\end{frame}
+
+\begin{frame}[t,fragile]{Wdh. Vererbung in Java}
+\protect\hypertarget{wdh.-vererbung-in-java-5}{}
+\vspace{1cm}
+
+Die Oberklasse ist über das Java Schlüsselwort
+\mintinline[]{java}{super} benutzbar.
+
+\vspace{1cm}
+\pause
+
+\begin{block}{Beispiele}
+\protect\hypertarget{beispiele}{}
+\begin{itemize}
+\tightlist
+\item
+ \mintinline[]{java}{super(...)} Konstruktoraufruf der Oberklasse
+\item
+ \mintinline[]{java}{super.zahl} Attribut der Oberklasse
+\item
+ \mintinline[]{java}{super.zahlGeben()} Methodenaufruf der Oberklasse
+\end{itemize}
+
+\pause
+
+\begin{tikzpicture}[overlay, remember picture]
+ \node[rotate=-30,scale=3] at (12, 3) {\Huge \color{red} \textbf{!}};
+\end{tikzpicture}
+\end{block}
+\end{frame}
+
+\begin{frame}[fragile]{Vererbung - Problem}
+\protect\hypertarget{vererbung---problem}{}
+\begin{tikzpicture}
+ \begin{class}[text width=4cm]{Sparkonto}{0,0}
+ \attribute{kontostand}
+ \attribute{kontonummer}
+ \attribute{zinssatz}
+ \operation{Einzahlen(betrag)}
+ \operation{Abheben(betrag)}
+ \operation{KontostandGeben()}
+ \operation{Verzinsen()}
+ \end{class}
+
+ \begin{class}[text width=4cm]{Girokonto}{5,0}
+ \attribute{kontostand}
+ \attribute{kontonummer}
+ \operation{Einzahlen(betrag)}
+ \operation{Abheben(betrag)}
+ \operation{KontostandGeben()}
+ \end{class}
+
+ \begin{class}[text width=4cm]{Firmenkonto}{10,0}
+ \attribute{kontostand}
+ \attribute{kontonummer}
+ \attribute{dispokredit}
+ \operation{Einzahlen(betrag)}
+ \operation{Abheben(betrag)}
+ \operation{KontostandGeben()}
+ \operation{DispokreditSetzen(wert)}
+ \end{class}
+\end{tikzpicture}
+
+\pause
+
+Mögliche Probleme dieser Modellierung?
+\end{frame}
+
+\begin{frame}[fragile]{Vererbung - Generalisierung}
+\protect\hypertarget{vererbung---generalisierung}{}
+\resizebox{!}{0.5\textheight}{
+\begin{tikzpicture}
+ \begin{class}[text width=4cm]{Sparkonto}{0,0}
+ \attribute{kontostand}
+ \attribute{kontonummer}
+ \attribute{zinssatz}
+ \operation{Einzahlen(betrag)}
+ \operation{Abheben(betrag)}
+ \operation{KontostandGeben()}
+ \operation{Verzinsen()}
+ \end{class}
+
+ \begin{class}[text width=4cm]{Girokonto}{5,0}
+ \attribute{kontostand}
+ \attribute{kontonummer}
+ \operation{Einzahlen(betrag)}
+ \operation{Abheben(betrag)}
+ \operation{KontostandGeben()}
+ \end{class}
+
+ \begin{class}[text width=4cm]{Firmenkonto}{10,0}
+ \attribute{kontostand}
+ \attribute{kontonummer}
+ \attribute{dispokredit}
+ \operation{Einzahlen(betrag)}
+ \operation{Abheben(betrag)}
+ \operation{KontostandGeben()}
+ \operation{DispokreditSetzen(wert)}
+ \end{class}
+\end{tikzpicture}
+}
+
+\textbf{Idee}: Auslagern der gemeinsamen Attribute und Methoden in eine
+Oberklasse
+
+\textbf{Arbeitsauftrag 3min}: Zeichne ein Klassendiagramm mit einer
+gemeinsamen Oberklasse
+\end{frame}
+
+\begin{frame}[fragile]{Generalisierung - KONTO}
+\protect\hypertarget{generalisierung---konto}{}
+\begin{tikzpicture}
+ \node[rotate=30,scale=3] at (0, 3) {\Huge \color{red} \textbf{!}};
+
+ \begin{class}[text width=4cm]{KONTO}{5,4}
+ \attribute{kontostand}
+ \attribute{kontonummer}
+ \operation{Einzahlen(betrag)}
+ \operation{Abheben(betrag)}
+ \operation{KontostandGeben()}
+ \end{class}
+
+ \begin{class}[text width=4cm]{SPARKONTO}{0,0}
+ \inherit{KONTO}
+ \attribute{zinssatz}
+ \operation{Verzinsen()}
+ \end{class}
+
+
+ \begin{class}[text width=4cm]{GIROKONTO}{5,0}
+ \inherit{KONTO}
+ \end{class}
+
+ \begin{class}[text width=4cm]{FIRMENKONTO}{10,0}
+ \inherit{KONTO}
+ \attribute{dispokredit}
+ \operation{DispokreditSetzen(wert)}
+ \end{class}
+\end{tikzpicture}
+\end{frame}
+
+\begin{frame}[fragile]{Generalisierung - Java}
+\protect\hypertarget{generalisierung---java}{}
+\small
+
+\begin{columns}[T]
+\begin{column}{0.5\textwidth}
+\begin{minted}[autogobble]{java}
+class Konto {
+ private int kontostand;
+ private int kontonummer;
+
+ public void Konto(int kNr) {
+ kontostand = 0;
+ kontonummer = kNr;
+ }
+
+ public void Einzahlen(int betrag) {
+ ...
+}
+\end{minted}
+\end{column}
+
+\begin{column}{0.5\textwidth}
+\begin{minted}[autogobble]{java}
+// Klassendefinition ?
+ private double zinssatz;
+
+ public void Sparkonto(int kNr,
+ double zs) {
+ // KONTO Initialisierung?
+ zinssatz = zs;
+ }
+
+ public void Verzinsen() {
+ ...
+}
+\end{minted}
+\end{column}
+\end{columns}
+\end{frame}
+
+\begin{frame}[fragile]{Generalisierung - Java}
+\protect\hypertarget{generalisierung---java-1}{}
+\small
+
+\begin{columns}[T]
+\begin{column}{0.5\textwidth}
+\begin{minted}[autogobble]{java}
+class Konto {
+ private int kontostand;
+ private int kontonummer;
+
+ public void Konto(int kNr) {
+ kontostand = 0;
+ kontonummer = kNr;
+ }
+
+ public void Einzahlen(int betrag) {
+ ...
+}
+\end{minted}
+\end{column}
+
+\begin{column}{0.5\textwidth}
+\begin{minted}[highlightlines={1},autogobble]{java}
+class Sparkonto extends Konto {
+ private double zinssatz;
+
+ public void Sparkonto(int kNr,
+ double zs) {
+ super(kNr);
+ zinssatz = zs;
+ }
+
+ public void Verzinsen() {
+ ...
+}
+\end{minted}
+\end{column}
+\end{columns}
+\end{frame}
+
+\begin{frame}[fragile]{Generalisierung - Java}
+\protect\hypertarget{generalisierung---java-2}{}
+\small
+
+\begin{columns}[T]
+\begin{column}{0.5\textwidth}
+\begin{minted}[autogobble]{java}
+class Konto {
+ private int kontostand;
+ private int kontonummer;
+
+ public void Konto(int kNr) {
+ kontostand = 0;
+ kontonummer = kNr;
+ }
+
+ public void Einzahlen(int betrag) {
+ ...
+}
+\end{minted}
+\end{column}
+
+\begin{column}{0.5\textwidth}
+\begin{minted}[highlightlines={1,6},autogobble]{java}
+class Sparkonto extends KONTO {
+ private double zinssatz;
+
+ public void Sparkonto(int kNr,
+ double zs) {
+ super(kNr);
+ zinssatz = zs;
+ }
+
+ public void Verzinsen() {
+ ...
+}
+\end{minted}
+\end{column}
+\end{columns}
+\end{frame}
+
+\begin{frame}[fragile]{Polymorphismus}
+\protect\hypertarget{polymorphismus}{}
+\begin{center}
+griechisch Vielgestaltigkeit
+\end{center}
+
+\hfill\break{\centering\includegraphics{img/wolpertinger}\par}
+\end{frame}
+
+\begin{frame}[fragile]{Arbeitsauftrag Tierheimverwaltung}
+\protect\hypertarget{arbeitsauftrag-tierheimverwaltung}{}
+\begin{itemize}
+\tightlist
+\item
+ \textbf{AUFGABE 0:} Mach dich Kurz mit dem Projekt Tierheim in der
+ Online-IDE vertraut
+\item
+ \textbf{AUFGABE 1:} Überlege dir wie du unterschiedliche Tiere im
+ Tierheim speicherst und setze deine Überlegung um
+\item
+ \textbf{AUFGABE 2:} Überlege dir warum Pluto (Objekte der Klasse Hund)
+ nicht ins Tierheim aufgenommen werden können
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]{Polymorphismus}
+\protect\hypertarget{polymorphismus-1}{}
+\emph{ist die Eigenschaft, dass ein \textbf{Referenzattribut} nicht nur
+Objekte der als Datentyp angegebenen Klasse referenzieren kann, sondern
+auch Objekte \textbf{aller} zu dieser Klasse existierenden
+\textbf{Unterklassen}.}
+\end{frame}
+
+\begin{frame}[fragile]{Polymorphismus}
+\protect\hypertarget{polymorphismus-2}{}
+\begin{tikzpicture}[scale=0.5]
+ \begin{object}[text width=3.5cm]{s1}{0,0}
+ \instanceOf{Tierheim}
+ \attribute{Tiere[0]}
+ \attribute{...}
+ \end{object}
+
+ \begin{object}[text width=4cm]{a1}{12,0}
+ \instanceOf{Tier}
+ \attribute{name="Wolle"}
+ \attribute{geschlecht="ungewiss"}
+ \end{object}
+
+ \begin{object}[text width=4cm]{a1}{12,5}
+ \instanceOf{Hund}
+ \attribute{name="Pluto" }
+ \attribute{geschlecht="maennlich"}
+ \attribute{rasse="comic"}
+ \end{object}
+
+ \only<2->{
+ \node[fill=black, circle, minimum size=0.075cm] (circle) at (2.2, -1.75) {};
+ }
+ \only<2> {
+ \draw[line width=2pt, -latex] (circle) edge [bend right=15] (8, -0.5) {};
+ }
+ \only<3> {
+ \draw[line width=2pt, -latex] (circle) edge [bend left=30] (8, 4.5) {};
+ }
+\end{tikzpicture}
+\end{frame}
+
+\begin{frame}[fragile]{Arbeitsauftrag Tierheimverwaltung Vorsetzung}
+\protect\hypertarget{arbeitsauftrag-tierheimverwaltung-vorsetzung}{}
+\begin{itemize}
+\tightlist
+\item
+ \textbf{AUFGABE 3:} Passe die Klasse Hund entsprechend an
+\item
+ \textbf{AUFGABE 4:} Implementiere die Methode
+ \mintinline[]{text}{Tierheim.besuchen()} und überlege dir welche
+ Ausgaben das Programm machen wird. Überprüfe deine Vermutung in dem du
+ das Programm ausführst.
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]{Polymorphismus}
+\protect\hypertarget{polymorphismus-3}{}
+\emph{ist die Eigenschaft, dass ein \textbf{Referenzattribut} nicht nur
+Objekte der als Datentyp angegebenen Klasse referenzieren kann, sondern
+auch Objekte \textbf{aller} zu dieser Klasse existierenden
+\textbf{Unterklassen}.}
+
+\vspace{0.25cm}
+
+\emph{Wird ein \textbf{Objekt einer Unterklasse} über dieses
+Referenzattribut referenziert, so werden Attribute und Methoden
+verwendet, wie sie in \textbf{seiner Klasse} bekannt sind (und nicht die
+überschriebenen Methoden der Oberklasse).}
+
+\pause
+
+\begin{tikzpicture}[overlay, remember picture]
+ \node[rotate=-20,scale=3] at (12, -0.5) {\Huge \color{red} \textbf{!}};
+\end{tikzpicture}
+\end{frame}
+
+\begin{frame}[fragile]{Beispiel}
+\protect\hypertarget{beispiel}{}
+Was gibt dieses Programm aus?
+
+\begin{minted}[autogobble]{java}
+Tier pluto = new Hund("pluto", "maennlich", "comic");
+pluto.gibLaut();
+\end{minted}
+
+\pause
+
+\begin{block}{Ausgabe}
+\protect\hypertarget{ausgabe}{}
+\mintinline[]{text}{Wuff}
+\end{block}
+
+Da der Polymorphismus dafür sorgt das die Methode wie sie in der
+Unterklasse \mintinline[]{text}{Hund} bekannt ist ausgeführt wird.
+\end{frame}
+
+\end{document}