{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"_Aufgabe 1_\n",
"\n",
"Sie entwickeln im Team ein CAD-Programm,\n",
"das das Zusammenstellen komplexer Zeichnungen aus einfachen 2D-Elementen erlaubt.\n",
"Gegeben ist bereits eine Klasse *Element*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"class Element():\n",
"\n",
" def get_bezeichnung(self):\n",
" return \"N.N.\"\n",
"\n",
" def umfang(self):\n",
" raise NotImplementedError()\n",
"\n",
" def __str__(self):\n",
" return self.get_bezeichnung() + f\" Umfang: {self.umfang()}\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ihr Teamleiter beauftragt Sie, für die Elemente *Kreis* und *Rechteck* Unterklassen\n",
"zur Oberklasse *Element* so zu implementieren,\n",
"dass anschließend die Aufrufe\n",
"\n",
"k = Kreis(radius=3)
\n",
"\n",
"r = Rechteck(breite=10, hoehe=5)
\n",
"\n",
"möglich sind.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import math\n",
"\n",
"\n",
"k = Kreis(radius=3)\n",
"print(k)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"\n",
"r = Rechteck(breite=10, hoehe=5)\n",
"print(r)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_Aufgabe 2_\n",
"\n",
"Fügen Sie jetzt noch eine weitere Klasse *Quadrat* hinzu. Welche Oberklasse besitzt diese neue Klasse?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"\n",
"q = Quadrat(seite=4)\n",
"print(q)\n",
"\n",
"\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}