-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (20 loc) · 649 Bytes
/
main.py
File metadata and controls
32 lines (20 loc) · 649 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from bubble_sort import BubbleSort
from selection_sort import SelectionSort
from sort_strategy import SortStrategy
if __name__ == '__main__':
# the list to sort
my_list = [1,2,3,4,5,6,7]
# bubbke sort algo
b = BubbleSort()
# Selection sort algo
s = SelectionSort()
# choosing the strategy - bubble sort
print("Bubble sort :")
strategy = SortStrategy(b)
sorted_list = strategy.sort(my_list)
print("result ", sorted_list)
# changing the strategy to Selection sort
print("Selection sort :")
strategy.algo = s
sorted_list = strategy.sort(my_list)
print("result ", sorted_list)