123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- {
- "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",
- "<code>k = Kreis(radius=3)</code>\n",
- "\n",
- "<code>r = Rechteck(breite=10, hoehe=5)</code>\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
- }
|