Skip to content

Commit e355a91

Browse files
committed
Refactor code
1 parent 59e44a6 commit e355a91

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

7-OOP/2-Abstraction/abstraction.ipynb

+9-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 6,
12+
"execution_count": 3,
1313
"metadata": {},
1414
"outputs": [],
1515
"source": [
@@ -26,7 +26,7 @@
2626
},
2727
{
2828
"cell_type": "code",
29-
"execution_count": 7,
29+
"execution_count": 4,
3030
"metadata": {},
3131
"outputs": [
3232
{
@@ -71,7 +71,7 @@
7171
},
7272
{
7373
"cell_type": "code",
74-
"execution_count": 11,
74+
"execution_count": 9,
7575
"metadata": {},
7676
"outputs": [
7777
{
@@ -87,7 +87,8 @@
8787
" \"\"\"Abstract base class representing a vehicle.\"\"\"\n",
8888
"\n",
8989
" @property\n",
90-
" def max_speed(self) -> float | None:\n",
90+
" @abstractmethod\n",
91+
" def max_speed(self) -> float:\n",
9192
" \"\"\"Maximum speed of the vehicle.\"\"\"\n",
9293
" pass\n",
9394
"\n",
@@ -96,10 +97,12 @@
9697
" \"\"\"Class representing a car.\"\"\"\n",
9798
"\n",
9899
" def __init__(self, max_speed: float) -> None:\n",
100+
" \"\"\"Initialize a car with a given maximum speed.\"\"\"\n",
99101
" self._max_speed = max_speed\n",
100102
"\n",
101103
" @property\n",
102104
" def max_speed(self) -> float:\n",
105+
" \"\"\"Return the maximum speed of the car.\"\"\"\n",
103106
" return self._max_speed\n",
104107
"\n",
105108
"\n",
@@ -116,7 +119,7 @@
116119
},
117120
{
118121
"cell_type": "code",
119-
"execution_count": 9,
122+
"execution_count": 6,
120123
"metadata": {},
121124
"outputs": [
122125
{
@@ -163,7 +166,7 @@
163166
},
164167
{
165168
"cell_type": "code",
166-
"execution_count": 10,
169+
"execution_count": 7,
167170
"metadata": {},
168171
"outputs": [
169172
{

0 commit comments

Comments
 (0)