summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiclas Dobbertin <niclas.dobbertin@mailbox.org>2023-07-20 12:12:24 +0200
committerNiclas Dobbertin <niclas.dobbertin@mailbox.org>2023-07-20 12:12:24 +0200
commit7b09467be0e904a1cae2c94187cc666b2a67889e (patch)
tree644f23988310f4410bb9c74b38d61882b0d82b0a
parent07183cd742f4cbbcad1b0770906f0adbd33f4512 (diff)
add frensch procedures
-rw-r--r--master_thesis/frensch_procedures.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/master_thesis/frensch_procedures.py b/master_thesis/frensch_procedures.py
new file mode 100644
index 0000000..88aa29d
--- /dev/null
+++ b/master_thesis/frensch_procedures.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python3
+
+from __future__ import annotations
+import random
+
+
+class WaterSample:
+ def __init__(
+ self,
+ solid: int,
+ algae: int,
+ lime: tuple[int, int, int, int],
+ toxin: tuple[int, int, int, int],
+ ):
+ self.solid = solid
+ self.algae = algae
+ self.lime = lime
+ self.toxin = toxin
+
+ def index1(self):
+ return (self.lime[3] - self.lime[1]) * self.solid
+
+ def index1_str(self):
+ return "(Lime_4 - Lime_2) * Solid"
+
+ def index2(self):
+ return (2 * self.algae) + min(self.lime)
+
+ def index2_str(self):
+ return "(2 * Algae) + Lime_min"
+
+ def index3(self):
+ return max(self.toxin) + min(self.toxin)
+
+ def index3_str(self):
+ return "Toxin_max + Toxin_min"
+
+ def index4(self):
+ return (self.solid * 2) - self.toxin[3]
+
+ def index4_str(self):
+ return "(Solid * 2) - Toxin_4"
+
+ def index5(self):
+ return max(self.lime[2], (self.toxin[2] - self.toxin[1]))
+
+ def index5_str(self):
+ return "Greater of [(Toxin_3 - Toxin_2), Lime_3]"
+
+ def overall(self):
+ return 100 - max(
+ self.index1(), self.index2(), self.index3(), self.index4(), self.index5()
+ )
+
+ def overall_str(self):
+ return "100 - Index_max"
+
+ def print_all(self):
+ print(f"Solid: {self.solid}")
+ print(f"Algae: {self.algae}")
+ print(f"Lime: {self.lime}")
+ print(f"Toxin: {self.toxin}")
+ print(f"Index 1: {self.index1_str()} = {self.index1()}")
+ print(f"Index 2: {self.index2_str()} = {self.index2()}")
+ print(f"Index 3: {self.index3_str()} = {self.index3()}")
+ print(f"Index 4: {self.index4_str()} = {self.index4()}")
+ print(f"Index 5: {self.index5_str()} = {self.index5()}")
+ print(f"Overall Quality: {self.overall_str()} = {self.overall()}")
+
+
+def random_WaterSample():
+ solid = random.randint(1, 9)
+ algae = random.randint(1, 9)
+ lime = tuple(random.randint(1, 9) for _ in range(4))
+ toxin = tuple(random.randint(1, 9) for _ in range(4))
+
+ return WaterSample(solid, algae, lime, toxin)
+