{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "960c0c2c",
   "metadata": {},
   "source": [
    "# 18-13 · Stan rysowania\n",
    "\n",
    "Praktyka do sekcji [„Stan rysowania”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "88d539b2",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Złożyć DrawingState jak dataclass i sprawdzić wybór narzędzia bez Tkinter."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cbd82626",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6bc7fc77",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T00:51:39.974289Z",
     "iopub.status.busy": "2026-09-03T00:51:39.974092Z",
     "iopub.status.idle": "2026-09-03T00:51:39.987756Z",
     "shell.execute_reply": "2026-09-03T00:51:39.987232Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DrawingState(tool=<Tool.RECTANGLE: 'rectangle'>, color='#2563eb', width=4)\n"
     ]
    }
   ],
   "source": [
    "from dataclasses import dataclass\n",
    "from enum import Enum\n",
    "\n",
    "\n",
    "class Tool(Enum):\n",
    "    PENCIL = \"pencil\"\n",
    "    LINE = \"line\"\n",
    "    RECTANGLE = \"rectangle\"\n",
    "    OVAL = \"oval\"\n",
    "    ERASER = \"eraser\"\n",
    "\n",
    "\n",
    "@dataclass\n",
    "class DrawingState:\n",
    "    tool: Tool = Tool.PENCIL\n",
    "    color: str = \"#111827\"\n",
    "    width: int = 4\n",
    "\n",
    "\n",
    "state = DrawingState()\n",
    "state.tool = Tool.RECTANGLE\n",
    "state.color = \"#2563eb\"\n",
    "print(state)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "005431ac",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3f77336b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T00:51:39.990078Z",
     "iopub.status.busy": "2026-09-03T00:51:39.989638Z",
     "iopub.status.idle": "2026-09-03T00:51:39.993986Z",
     "shell.execute_reply": "2026-09-03T00:51:39.993323Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Инструмент, цвет и толщина живут в одном объекте состояния.\n"
     ]
    }
   ],
   "source": [
    "assert state.tool is Tool.RECTANGLE\n",
    "assert state.color == \"#2563eb\"\n",
    "assert state.width == 4\n",
    "print(\"Инструмент, цвет и толщина живут в одном объекте состояния.\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "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.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
