We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 170bf88 commit 92a4fd3Copy full SHA for 92a4fd3
Sorting Visualizer/algorithms.py
@@ -1,7 +1,8 @@
1
import time
2
import random
3
+from abc import ABCMeta, abstractmethod
4
-class Algorithm:
5
+class Algorithm(metaclass=ABCMeta):
6
def __init__(self, name):
7
self.array = random.sample(range(512), 512) # Random array of size 512
8
self.name = name # Get name of the variable
@@ -15,6 +16,10 @@ def run(self): # Start the timer and run the algorithm
15
16
self.algorithm()
17
time_elapsed = time.time() - self.start_time
18
return self.array, time_elapsed
19
+
20
+ @abstractmethod
21
+ def algorithm(self):
22
+ raise TypeError(f"Algorithm.algorithm() has not been overwritten.")
23
24
25
class SelectionSort(Algorithm):
0 commit comments