You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

083a Uebung.ipynb 2.6KB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {
  6. "collapsed": true,
  7. "pycharm": {
  8. "name": "#%% md\n"
  9. }
  10. },
  11. "source": [
  12. "_Aufgabe 1_\n",
  13. "\n",
  14. "Sie entwickeln im Team ein CAD-Programm,\n",
  15. "das das Zusammenstellen komplexer Zeichnungen aus einfachen 2D-Elementen erlaubt.\n",
  16. "Gegeben ist bereits eine Klasse *Element*."
  17. ]
  18. },
  19. {
  20. "cell_type": "code",
  21. "execution_count": null,
  22. "metadata": {
  23. "pycharm": {
  24. "name": "#%%\n"
  25. }
  26. },
  27. "outputs": [],
  28. "source": [
  29. "class Element():\n",
  30. "\n",
  31. " def get_bezeichnung(self):\n",
  32. " return \"N.N.\"\n",
  33. "\n",
  34. " def umfang(self):\n",
  35. " raise NotImplementedError()\n",
  36. "\n",
  37. " def __str__(self):\n",
  38. " return self.get_bezeichnung() + f\" Umfang: {self.umfang()}\""
  39. ]
  40. },
  41. {
  42. "cell_type": "markdown",
  43. "metadata": {},
  44. "source": [
  45. "Ihr Teamleiter beauftragt Sie, für die Elemente *Kreis* und *Rechteck* Unterklassen\n",
  46. "zur Oberklasse *Element* so zu implementieren,\n",
  47. "dass anschließend die Aufrufe\n",
  48. "\n",
  49. "<code>k = Kreis(radius=3)</code>\n",
  50. "\n",
  51. "<code>r = Rechteck(breite=10, hoehe=5)</code>\n",
  52. "\n",
  53. "möglich sind.\n"
  54. ]
  55. },
  56. {
  57. "cell_type": "code",
  58. "execution_count": null,
  59. "metadata": {
  60. "pycharm": {
  61. "name": "#%%\n"
  62. }
  63. },
  64. "outputs": [],
  65. "source": [
  66. "import math\n",
  67. "\n",
  68. "\n",
  69. "k = Kreis(radius=3)\n",
  70. "print(k)"
  71. ]
  72. },
  73. {
  74. "cell_type": "code",
  75. "execution_count": null,
  76. "metadata": {
  77. "pycharm": {
  78. "name": "#%%\n"
  79. }
  80. },
  81. "outputs": [],
  82. "source": [
  83. "\n",
  84. "r = Rechteck(breite=10, hoehe=5)\n",
  85. "print(r)"
  86. ]
  87. },
  88. {
  89. "cell_type": "markdown",
  90. "metadata": {},
  91. "source": [
  92. "_Aufgabe 2_\n",
  93. "\n",
  94. "Fügen Sie jetzt noch eine weitere Klasse *Quadrat* hinzu. Welche Oberklasse besitzt diese neue Klasse?"
  95. ]
  96. },
  97. {
  98. "cell_type": "code",
  99. "execution_count": null,
  100. "metadata": {
  101. "pycharm": {
  102. "name": "#%%\n"
  103. }
  104. },
  105. "outputs": [],
  106. "source": [
  107. "\n",
  108. "q = Quadrat(seite=4)\n",
  109. "print(q)\n",
  110. "\n",
  111. "\n",
  112. "\n"
  113. ]
  114. }
  115. ],
  116. "metadata": {
  117. "kernelspec": {
  118. "display_name": "Python 3",
  119. "language": "python",
  120. "name": "python3"
  121. },
  122. "language_info": {
  123. "codemirror_mode": {
  124. "name": "ipython",
  125. "version": 3
  126. },
  127. "file_extension": ".py",
  128. "mimetype": "text/x-python",
  129. "name": "python",
  130. "nbconvert_exporter": "python",
  131. "pygments_lexer": "ipython3",
  132. "version": "3.8.2"
  133. }
  134. },
  135. "nbformat": 4,
  136. "nbformat_minor": 1
  137. }