{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "384046f1",
   "metadata": {},
   "source": [
    "# 14-15 · Dziedzictwo\n",
    "\n",
    "Praktyka do sekcji [„Dziedziczenie”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e2bf891",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "IS-A relacja: class Child(Parent) ponownie wykorzystuje wspólne zachowanie."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "476404bd",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ce8442aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Zhivotnoe:\n",
    "    def __init__(self, klichka):\n",
    "        self.klichka = klichka\n",
    "\n",
    "    def predstavitsya(self):\n",
    "        return f\"Я {self.klichka}\"\n",
    "\n",
    "\n",
    "class Sobaka(Zhivotnoe):\n",
    "    def zvuk(self):\n",
    "        return \"Гав!\"\n",
    "\n",
    "\n",
    "class Koshka(Zhivotnoe):\n",
    "    def zvuk(self):\n",
    "        return \"Мяу!\"\n",
    "\n",
    "rex = Sobaka(\"Рекс\")\n",
    "print(rex.predstavitsya(), rex.zvuk())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "beea455b",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Utwórz klasę `Korova(Zhivotnoe)` swoją metodą `zvuk()`odpowiedział „Mu!”"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "54a1a32e",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Korova(Zhivotnoe):\n",
    "    def zvuk(self):\n",
    "        return \"Му!\"\n",
    "\n",
    "burenka = Korova(\"Бурёнка\")\n",
    "print(burenka.predstavitsya(), burenka.zvuk())\n",
    "print(isinstance(burenka, Zhivotnoe))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "name": "python",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
