Skip to content

Commit cf5f268

Browse files
committed
updates
1 parent 1f2d5ee commit cf5f268

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

abstract_factory/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Your Python code may produce errors. It happens to everybody. It is hard to fore
6060

6161
Use the `Try`, `Except` and optional `finally` keywords to manage error handling.
6262

63-
In the example code, if no chair or table is returned, an `Exception` error is raised and it includes a text string that can be read and written to the console.
63+
In the example code, if no chair or table is returned, an `Exception` error is raised, and it includes a text string that can be read and written to the console.
6464

6565
Within your code you can use the `raise` keyword to trigger Python built in exceptions or even create your own.
6666

@@ -69,9 +69,9 @@ def get_furniture(furniture):
6969
"Static get_factory method"
7070
try:
7171
if furniture in ['SmallChair', 'MediumChair', 'BigChair']:
72-
return ChairFactory().get_chair(furniture)
72+
return ChairFactory.get_chair(furniture)
7373
if furniture in ['SmallTable', 'MediumTable', 'BigTable']:
74-
return TableFactory().get_table(furniture)
74+
return TableFactory.get_table(furniture)
7575
raise Exception('No Factory Found')
7676
except Exception as _e:
7777
print(_e)
@@ -97,7 +97,7 @@ The `try/except` allows the program to continue running, as can be verified by t
9797

9898
Alternatively, if your code didn't include the `try/except` and optional `finally` statements, the Python interpreter would return the error `NameError: name 'my_var' is not defined` and the program will crash at that line.
9999

100-
Also note how the default Python inbuilt error starts with `NameError` . You can handle this specific error explicitly using an extra `except` keyword.
100+
Also note how the default Python inbuilt error starts with `NameError`. You can handle this specific error explicitly using an extra `except` keyword.
101101

102102
``` python
103103
try:

abstract_factory/abstract_factory_concept.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def create_object(factory):
2222
"Static get_factory method"
2323
try:
2424
if factory in ['aa', 'ab', 'ac']:
25-
return FactoryA().create_object(factory[1])
25+
return FactoryA.create_object(factory[1])
2626
if factory in ['ba', 'bb', 'bc']:
27-
return FactoryB().create_object(factory[1])
27+
return FactoryB.create_object(factory[1])
2828
raise Exception('No Factory Found')
2929
except Exception as _e:
3030
print(_e)

abstract_factory/furniture_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def get_furniture(furniture):
1313
"Static get_factory method"
1414
try:
1515
if furniture in ['SmallChair', 'MediumChair', 'BigChair']:
16-
return ChairFactory().get_chair(furniture)
16+
return ChairFactory.get_chair(furniture)
1717
if furniture in ['SmallTable', 'MediumTable', 'BigTable']:
18-
return TableFactory().get_table(furniture)
18+
return TableFactory.get_table(furniture)
1919
raise Exception('No Factory Found')
2020
except Exception as _e:
2121
print(_e)

0 commit comments

Comments
 (0)