Skip to content

Commit 48cb363

Browse files
committed
reformatting with black
1 parent 7167f56 commit 48cb363

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

chapter01_strategy/duck.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
class FlyBehavior():
1+
class FlyBehavior:
32
def fly(self):
43
raise NotImplementedError
54

@@ -19,7 +18,7 @@ def fly(self):
1918
print("I'm flying with a rocket!'")
2019

2120

22-
class QuackBehavior():
21+
class QuackBehavior:
2322
def quack(self):
2423
raise NotImplementedError
2524

@@ -39,7 +38,7 @@ def quack(self):
3938
print("Squeak")
4039

4140

42-
class Duck():
41+
class Duck:
4342
fly_behavior = None
4443
quack_behavior = None
4544

@@ -89,5 +88,5 @@ def mini_duck_simulator():
8988
model.perform_fly()
9089

9190

92-
if __name__ == '__main__':
91+
if __name__ == "__main__":
9392
mini_duck_simulator()

chapter02_observer/weather.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Subject():
1+
class Subject:
22
def register_observer():
33
raise NotImplementedError
44

@@ -9,12 +9,12 @@ def notify_observers():
99
raise NotImplementedError
1010

1111

12-
class Observer():
12+
class Observer:
1313
def update():
1414
raise NotImplementedError
1515

1616

17-
class DisplayElement():
17+
class DisplayElement:
1818
def display():
1919
raise NotImplementedError
2020

@@ -49,7 +49,8 @@ def __init__(self, weather_data):
4949

5050
def display(self):
5151
print(
52-
f"Current conditions: {self._temperature:.1f}F degrees and {self._humidity:.1f}% humidity")
52+
f"Current conditions: {self._temperature:.1f}F degrees and {self._humidity:.1f}% humidity"
53+
)
5354

5455
def update(self, temperature: float, humidity: float, pressure: float):
5556
self._temperature = temperature
@@ -60,11 +61,11 @@ def update(self, temperature: float, humidity: float, pressure: float):
6061
def weather_station():
6162
weather_data = WeatherData()
6263
current_display = CurrentConditionsDisplay(weather_data)
63-
# statistics_display = StatisticsDisplay(weather_data)
64+
# statistics_display = StatisticsDisplay(weather_data)
6465
weather_data.set_measurements(80, 65, 30.4)
6566
weather_data.set_measurements(82, 70, 29.2)
6667
weather_data.set_measurements(78, 90, 29.2)
6768

6869

69-
if __name__ == '__main__':
70+
if __name__ == "__main__":
7071
weather_station()

chapter03_decorator/coffee.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
# TODO : Add Dark roast, Soy, Whip
44

5+
56
class Beverage(abc.ABC):
67
"""Base class for all beverages"""
8+
79
def __init__(self):
8-
self.description = 'Unknown Beverage'
10+
self.description = "Unknown Beverage"
911

1012
def get_description(self):
1113
return self.description
@@ -17,22 +19,23 @@ def cost(self):
1719

1820
class CondimentDecorator(Beverage, abc.ABC):
1921
"""Base class for all condiments"""
22+
2023
@abc.abstractmethod
2124
def get_description(self):
2225
raise NotImplementedError
2326

2427

2528
class Espresso(Beverage):
2629
def __init__(self):
27-
self.description = 'Espresso'
30+
self.description = "Espresso"
2831

2932
def cost(self):
3033
return 1.99
3134

3235

3336
class HouseBlend(Beverage):
3437
def __init__(self):
35-
self.description = 'House Blend Coffee'
38+
self.description = "House Blend Coffee"
3639

3740
def cost(self):
3841
return 0.89
@@ -43,7 +46,7 @@ def __init__(self, beverage: Beverage):
4346
self.beverage = beverage
4447

4548
def get_description(self):
46-
return self.beverage.get_description() + ', Mocha'
49+
return self.beverage.get_description() + ", Mocha"
4750

4851
def cost(self):
4952
return self.beverage.cost() + 0.20
@@ -60,5 +63,5 @@ def star_buzz_coffee():
6063
print(beverage3.get_description(), beverage3.cost())
6164

6265

63-
if __name__ == '__main__':
66+
if __name__ == "__main__":
6467
star_buzz_coffee()

0 commit comments

Comments
 (0)