From d1c1af3490056b769d9bae7b5ca58d8b050b1f96 Mon Sep 17 00:00:00 2001 From: VirajRaut Date: Thu, 16 Nov 2023 14:13:23 +0530 Subject: [PATCH 1/5] initial commit --- car.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/car.py b/car.py index f7b980a1b..a394e6ab3 100644 --- a/car.py +++ b/car.py @@ -7,4 +7,4 @@ def __init__(self, last_service_date): @abstractmethod def needs_service(self): - pass + print("My name is Viraj") From 78054ea0954a847303aae384fb36df4d686bc401 Mon Sep 17 00:00:00 2001 From: VirajRaut Date: Thu, 16 Nov 2023 14:17:40 +0530 Subject: [PATCH 2/5] Refactoring --- engine/__init__.py => __init__.py | 0 battery/Battery.py | 7 +++++ battery/NubbinBattery.py | 23 ++++++++++++++ battery/SpindlerBattery.py | 24 ++++++++++++++ {engine/model => battery}/__init__.py | 0 car.py | 10 ------ carFactory.py | 45 +++++++++++++++++++++++++++ engine/Engine.py | 7 +++++ engine/capulet_engine.py | 18 ++++++----- engine/model/calliope.py | 12 ------- engine/model/glissade.py | 12 ------- engine/model/palindrome.py | 12 ------- engine/model/rorschach.py | 12 ------- engine/model/thovex.py | 12 ------- engine/sternman_engine.py | 15 ++++----- engine/willoughby_engine.py | 18 ++++++----- 16 files changed, 134 insertions(+), 93 deletions(-) rename engine/__init__.py => __init__.py (100%) create mode 100644 battery/Battery.py create mode 100644 battery/NubbinBattery.py create mode 100644 battery/SpindlerBattery.py rename {engine/model => battery}/__init__.py (100%) delete mode 100644 car.py create mode 100644 carFactory.py create mode 100644 engine/Engine.py delete mode 100644 engine/model/calliope.py delete mode 100644 engine/model/glissade.py delete mode 100644 engine/model/palindrome.py delete mode 100644 engine/model/rorschach.py delete mode 100644 engine/model/thovex.py diff --git a/engine/__init__.py b/__init__.py similarity index 100% rename from engine/__init__.py rename to __init__.py diff --git a/battery/Battery.py b/battery/Battery.py new file mode 100644 index 000000000..fb34ead8c --- /dev/null +++ b/battery/Battery.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class Battery(ABC): + @abstractmethod + def needs_service(): + pass diff --git a/battery/NubbinBattery.py b/battery/NubbinBattery.py new file mode 100644 index 000000000..6f18f663f --- /dev/null +++ b/battery/NubbinBattery.py @@ -0,0 +1,23 @@ +from battery.Battery import Battery +from datetime import datetime + +class NubbinBattery(Battery): + def __init__(self, last_service_date): + self.last_service_date = last_service_date + self.current_data = datetime.today().date() + + def needs_service(self): + service_threshold_date = self.last_service_date.replace( + year=self.last_service_date.year + 2) + if service_threshold_date < datetime.today().date(): + return True + else: + return False + + +if __name__ == "__main__": + today = datetime.today().date() + last_service_date = today.replace(year=today.year - 2) + print(last_service_date) + nb = NubbinBattery(last_service_date) + print(nb.needs_service()) diff --git a/battery/SpindlerBattery.py b/battery/SpindlerBattery.py new file mode 100644 index 000000000..c06ecb76e --- /dev/null +++ b/battery/SpindlerBattery.py @@ -0,0 +1,24 @@ +from battery.Battery import Battery +from datetime import datetime + + +class SpindlerBattery(Battery): + def __init__(self, last_service_date): + self.last_service_date = last_service_date + self.current_data = datetime.today().date() + + def needs_service(self): + service_threshold_date = self.last_service_date.replace( + year=self.last_service_date.year + 4) + if service_threshold_date < datetime.today().date(): + return True + else: + return False + + +if __name__ == "__main__": + today = datetime.today().date() + last_service_date = today.replace(year=today.year - 5) + print(last_service_date) + nb = SpindlerBattery(last_service_date) + print(nb.needs_service()) diff --git a/engine/model/__init__.py b/battery/__init__.py similarity index 100% rename from engine/model/__init__.py rename to battery/__init__.py diff --git a/car.py b/car.py deleted file mode 100644 index a394e6ab3..000000000 --- a/car.py +++ /dev/null @@ -1,10 +0,0 @@ -from abc import ABC, abstractmethod - - -class Car(ABC): - def __init__(self, last_service_date): - self.last_service_date = last_service_date - - @abstractmethod - def needs_service(self): - print("My name is Viraj") diff --git a/carFactory.py b/carFactory.py new file mode 100644 index 000000000..7d3dca186 --- /dev/null +++ b/carFactory.py @@ -0,0 +1,45 @@ +from datetime import datetime + +from battery.NubbinBattery import NubbinBattery +from battery.SpindlerBattery import SpindlerBattery + +from engine.capulet_engine import CapuletEngine +from engine.sternman_engine import SternmanEngine +from engine.willoughby_engine import WilloughbyEngine + +from car import Car + + +class CarFactory(): + + def create_calliope(self, last_service_date, current_mileage, last_service_mileage): + ce = CapuletEngine(last_service_mileage, current_mileage) + sb = SpindlerBattery(last_service_date) + self.car = Car(ce, sb) + + def create_glissade(self, last_service_date, current_mileage, last_service_mileage): + we = WilloughbyEngine(last_service_mileage, current_mileage) + sb = SpindlerBattery(last_service_date) + self.car = Car(we, sb) + + def create_palindrome(self, last_service_date, warning_light_is_on): + se = SternmanEngine(warning_light_is_on) + sb = SpindlerBattery(last_service_date) + self.car = Car(se, sb) + + def create_rorschach(self, last_service_date, current_mileage, last_service_mileage): + we = WilloughbyEngine(last_service_mileage, current_mileage) + nb = NubbinBattery(last_service_date) + self.car = Car(we, nb) + + def create_thovex(self, last_service_date, current_mileage, last_service_mileage): + we = CapuletEngine(last_service_mileage, current_mileage) + nb = NubbinBattery(last_service_date) + self.car = Car(we, nb) + +if __name__ == "__main__": + + today = datetime.today().date() + cf = CarFactory() + cf.create_calliope(today,30001,0) + print(cf.car.needs_service()) diff --git a/engine/Engine.py b/engine/Engine.py new file mode 100644 index 000000000..98504e848 --- /dev/null +++ b/engine/Engine.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class Engine(ABC): + @abstractmethod + def needs_service(): + pass diff --git a/engine/capulet_engine.py b/engine/capulet_engine.py index 69a2f3319..32ea6e30c 100644 --- a/engine/capulet_engine.py +++ b/engine/capulet_engine.py @@ -1,13 +1,15 @@ -from abc import ABC +from engine.Engine import Engine -from car import Car - -class CapuletEngine(Car, ABC): - def __init__(self, last_service_date, current_mileage, last_service_mileage): - super().__init__(last_service_date) - self.current_mileage = current_mileage +class CapuletEngine(Engine): + def __init__(self, last_service_mileage, current_mileage): self.last_service_mileage = last_service_mileage + self.current_mileage = current_mileage - def engine_should_be_serviced(self): + def needs_service(self): return self.current_mileage - self.last_service_mileage > 30000 + + +if __name__ == "__main__": + ce = CapuletEngine(0, 30001) + print(ce.needs_service()) diff --git a/engine/model/calliope.py b/engine/model/calliope.py deleted file mode 100644 index 1dd3da56d..000000000 --- a/engine/model/calliope.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.capulet_engine import CapuletEngine - - -class Calliope(CapuletEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 2) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/model/glissade.py b/engine/model/glissade.py deleted file mode 100644 index e1b16ad27..000000000 --- a/engine/model/glissade.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.willoughby_engine import WilloughbyEngine - - -class Glissade(WilloughbyEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 2) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/model/palindrome.py b/engine/model/palindrome.py deleted file mode 100644 index 590864bc8..000000000 --- a/engine/model/palindrome.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.sternman_engine import SternmanEngine - - -class Palindrome(SternmanEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 4) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/model/rorschach.py b/engine/model/rorschach.py deleted file mode 100644 index b9eedc91d..000000000 --- a/engine/model/rorschach.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.willoughby_engine import WilloughbyEngine - - -class Rorschach(WilloughbyEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 4) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/model/thovex.py b/engine/model/thovex.py deleted file mode 100644 index eac5707f0..000000000 --- a/engine/model/thovex.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.capulet_engine import CapuletEngine - - -class Thovex(CapuletEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 4) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/sternman_engine.py b/engine/sternman_engine.py index 72d8b5ab3..3d4448a9e 100644 --- a/engine/sternman_engine.py +++ b/engine/sternman_engine.py @@ -1,15 +1,16 @@ -from abc import ABC +from engine.Engine import Engine -from car import Car - -class SternmanEngine(Car, ABC): - def __init__(self, last_service_date, warning_light_is_on): - super().__init__(last_service_date) +class SternmanEngine(Engine): + def __init__(self, warning_light_is_on): self.warning_light_is_on = warning_light_is_on - def engine_should_be_serviced(self): + def needs_service(self): if self.warning_light_is_on: return True else: return False + +if __name__ == "__main__": + se = SternmanEngine(True) + print(se.needs_service()) diff --git a/engine/willoughby_engine.py b/engine/willoughby_engine.py index e5e0dc581..4360368fb 100644 --- a/engine/willoughby_engine.py +++ b/engine/willoughby_engine.py @@ -1,13 +1,15 @@ -from abc import ABC +from engine.Engine import Engine -from car import Car - -class WilloughbyEngine(Car, ABC): - def __init__(self, last_service_date, current_mileage, last_service_mileage): - super().__init__(last_service_date) - self.current_mileage = current_mileage +class WilloughbyEngine(Engine): + def __init__(self, last_service_mileage, current_mileage): self.last_service_mileage = last_service_mileage + self.current_mileage = current_mileage - def engine_should_be_serviced(self): + def needs_service(self): return self.current_mileage - self.last_service_mileage > 60000 + + +if __name__ == "__main__": + ce = WilloughbyEngine(0, 30001) + print(ce.needs_service()) From c6a178dcf348e8e7c3e4656d78b0a8205896a3a8 Mon Sep 17 00:00:00 2001 From: VirajRaut Date: Thu, 16 Nov 2023 14:24:04 +0530 Subject: [PATCH 3/5] Added car.py --- car.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 car.py diff --git a/car.py b/car.py new file mode 100644 index 000000000..bab3b7ffd --- /dev/null +++ b/car.py @@ -0,0 +1,19 @@ +from abc import ABC, abstractmethod + + +class Serviceable(ABC): + @abstractmethod + def needs_service(self): + pass + + +class Car(Serviceable): + def __init__(self, engine, battery): + self.engine = engine + self.battery = battery + + def needs_service(self): + if self.engine.needs_service() or self.battery.needs_service(): + return True + else: + return False From c05ee986de5ef71b42cb5af3300991ef4617bce1 Mon Sep 17 00:00:00 2001 From: VirajRaut Date: Thu, 16 Nov 2023 15:09:03 +0530 Subject: [PATCH 4/5] Unit Testing --- battery/NubbinBattery.py | 2 +- battery/SpindlerBattery.py | 2 +- test/__init__.py | 0 test/test_car.py => test_car.py | 128 +++++++++++++++++++------------- 4 files changed, 80 insertions(+), 52 deletions(-) delete mode 100644 test/__init__.py rename test/test_car.py => test_car.py (51%) diff --git a/battery/NubbinBattery.py b/battery/NubbinBattery.py index 6f18f663f..0799ed969 100644 --- a/battery/NubbinBattery.py +++ b/battery/NubbinBattery.py @@ -8,7 +8,7 @@ def __init__(self, last_service_date): def needs_service(self): service_threshold_date = self.last_service_date.replace( - year=self.last_service_date.year + 2) + year=self.last_service_date.year + 4) if service_threshold_date < datetime.today().date(): return True else: diff --git a/battery/SpindlerBattery.py b/battery/SpindlerBattery.py index c06ecb76e..19ff64793 100644 --- a/battery/SpindlerBattery.py +++ b/battery/SpindlerBattery.py @@ -9,7 +9,7 @@ def __init__(self, last_service_date): def needs_service(self): service_threshold_date = self.last_service_date.replace( - year=self.last_service_date.year + 4) + year=self.last_service_date.year + 2) if service_threshold_date < datetime.today().date(): return True else: diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/test_car.py b/test_car.py similarity index 51% rename from test/test_car.py rename to test_car.py index f5994670d..9f7e6c602 100644 --- a/test/test_car.py +++ b/test_car.py @@ -1,11 +1,7 @@ import unittest from datetime import datetime -from engine.model.calliope import Calliope -from engine.model.glissade import Glissade -from engine.model.palindrome import Palindrome -from engine.model.rorschach import Rorschach -from engine.model.thovex import Thovex +from carFactory import CarFactory class TestCalliope(unittest.TestCase): @@ -14,34 +10,38 @@ def test_battery_should_be_serviced(self): last_service_date = today.replace(year=today.year - 3) current_mileage = 0 last_service_mileage = 0 - - car = Calliope(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_calliope(last_service_date, + current_mileage, last_service_mileage) + self.assertTrue(cf.car.needs_service()) def test_battery_should_not_be_serviced(self): today = datetime.today().date() last_service_date = today.replace(year=today.year - 1) current_mileage = 0 last_service_mileage = 0 - - car = Calliope(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_calliope(last_service_date, + current_mileage, last_service_mileage) + self.assertFalse(cf.car.needs_service()) def test_engine_should_be_serviced(self): last_service_date = datetime.today().date() current_mileage = 30001 last_service_mileage = 0 - - car = Calliope(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_calliope(last_service_date, + current_mileage, last_service_mileage) + self.assertTrue(cf.car.needs_service()) def test_engine_should_not_be_serviced(self): last_service_date = datetime.today().date() current_mileage = 30000 last_service_mileage = 0 - - car = Calliope(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_calliope(last_service_date, + current_mileage, last_service_mileage) + self.assertFalse(cf.car.needs_service()) class TestGlissade(unittest.TestCase): @@ -51,8 +51,10 @@ def test_battery_should_be_serviced(self): current_mileage = 0 last_service_mileage = 0 - car = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_glissade(last_service_date, + current_mileage, last_service_mileage) + self.assertTrue(cf.car.needs_service()) def test_battery_should_not_be_serviced(self): today = datetime.today().date() @@ -60,24 +62,30 @@ def test_battery_should_not_be_serviced(self): current_mileage = 0 last_service_mileage = 0 - car = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_glissade(last_service_date, + current_mileage, last_service_mileage) + self.assertFalse(cf.car.needs_service()) def test_engine_should_be_serviced(self): last_service_date = datetime.today().date() current_mileage = 60001 last_service_mileage = 0 - car = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_glissade(last_service_date, + current_mileage, last_service_mileage) + self.assertTrue(cf.car.needs_service()) def test_engine_should_not_be_serviced(self): last_service_date = datetime.today().date() current_mileage = 60000 last_service_mileage = 0 - car = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_glissade(last_service_date, + current_mileage, last_service_mileage) + self.assertFalse(cf.car.needs_service()) class TestPalindrome(unittest.TestCase): @@ -86,30 +94,34 @@ def test_battery_should_be_serviced(self): last_service_date = today.replace(year=today.year - 5) warning_light_is_on = False - car = Palindrome(last_service_date, warning_light_is_on) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_palindrome(last_service_date, warning_light_is_on) + self.assertTrue(cf.car.needs_service()) def test_battery_should_not_be_serviced(self): today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) + last_service_date = today.replace(year=today.year - 2) warning_light_is_on = False - car = Palindrome(last_service_date, warning_light_is_on) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_palindrome(last_service_date, warning_light_is_on) + self.assertFalse(cf.car.needs_service()) def test_engine_should_be_serviced(self): last_service_date = datetime.today().date() warning_light_is_on = True - car = Palindrome(last_service_date, warning_light_is_on) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_palindrome(last_service_date, warning_light_is_on) + self.assertTrue(cf.car.needs_service()) def test_engine_should_not_be_serviced(self): last_service_date = datetime.today().date() warning_light_is_on = False - car = Palindrome(last_service_date, warning_light_is_on) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_palindrome(last_service_date, warning_light_is_on) + self.assertFalse(cf.car.needs_service()) class TestRorschach(unittest.TestCase): @@ -119,8 +131,10 @@ def test_battery_should_be_serviced(self): current_mileage = 0 last_service_mileage = 0 - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_rorschach(last_service_date, + current_mileage, last_service_mileage) + self.assertTrue(cf.car.needs_service()) def test_battery_should_not_be_serviced(self): today = datetime.today().date() @@ -128,24 +142,30 @@ def test_battery_should_not_be_serviced(self): current_mileage = 0 last_service_mileage = 0 - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_rorschach(last_service_date, + current_mileage, last_service_mileage) + self.assertFalse(cf.car.needs_service()) def test_engine_should_be_serviced(self): last_service_date = datetime.today().date() current_mileage = 60001 last_service_mileage = 0 - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_rorschach(last_service_date, + current_mileage, last_service_mileage) + self.assertTrue(cf.car.needs_service()) def test_engine_should_not_be_serviced(self): last_service_date = datetime.today().date() current_mileage = 60000 last_service_mileage = 0 - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_rorschach(last_service_date, + current_mileage, last_service_mileage) + self.assertFalse(cf.car.needs_service()) class TestThovex(unittest.TestCase): @@ -155,8 +175,10 @@ def test_battery_should_be_serviced(self): current_mileage = 0 last_service_mileage = 0 - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_thovex(last_service_date, current_mileage, + last_service_mileage) + self.assertTrue(cf.car.needs_service()) def test_battery_should_not_be_serviced(self): today = datetime.today().date() @@ -164,24 +186,30 @@ def test_battery_should_not_be_serviced(self): current_mileage = 0 last_service_mileage = 0 - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_thovex(last_service_date, current_mileage, + last_service_mileage) + self.assertFalse(cf.car.needs_service()) def test_engine_should_be_serviced(self): last_service_date = datetime.today().date() current_mileage = 30001 last_service_mileage = 0 - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) + cf = CarFactory() + cf.create_thovex(last_service_date, current_mileage, + last_service_mileage) + self.assertTrue(cf.car.needs_service()) def test_engine_should_not_be_serviced(self): last_service_date = datetime.today().date() current_mileage = 30000 last_service_mileage = 0 - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) + cf = CarFactory() + cf.create_thovex(last_service_date, current_mileage, + last_service_mileage) + self.assertFalse(cf.car.needs_service()) if __name__ == '__main__': From 91536a8f57c7455182be9c3ad6314a485d0c494f Mon Sep 17 00:00:00 2001 From: VirajRaut Date: Thu, 16 Nov 2023 15:32:57 +0530 Subject: [PATCH 5/5] Upgraded Spindler and Added Tire --- battery/SpindlerBattery.py | 2 +- car.py | 5 +++-- tire/Tire.py | 7 +++++++ tire/__init__.py | 0 tire/carrigan.py | 19 +++++++++++++++++++ tire/octoprime.py | 22 ++++++++++++++++++++++ 6 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 tire/Tire.py create mode 100644 tire/__init__.py create mode 100644 tire/carrigan.py create mode 100644 tire/octoprime.py diff --git a/battery/SpindlerBattery.py b/battery/SpindlerBattery.py index 19ff64793..bc450225d 100644 --- a/battery/SpindlerBattery.py +++ b/battery/SpindlerBattery.py @@ -9,7 +9,7 @@ def __init__(self, last_service_date): def needs_service(self): service_threshold_date = self.last_service_date.replace( - year=self.last_service_date.year + 2) + year=self.last_service_date.year + 3) if service_threshold_date < datetime.today().date(): return True else: diff --git a/car.py b/car.py index bab3b7ffd..4876e0939 100644 --- a/car.py +++ b/car.py @@ -8,12 +8,13 @@ def needs_service(self): class Car(Serviceable): - def __init__(self, engine, battery): + def __init__(self, engine, battery, tire): self.engine = engine self.battery = battery + self.tire = tire def needs_service(self): - if self.engine.needs_service() or self.battery.needs_service(): + if self.engine.needs_service() or self.battery.needs_service() or self.tire.needs_service(): return True else: return False diff --git a/tire/Tire.py b/tire/Tire.py new file mode 100644 index 000000000..958306290 --- /dev/null +++ b/tire/Tire.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class Tire(ABC): + @abstractmethod + def needs_service(): + pass diff --git a/tire/__init__.py b/tire/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tire/carrigan.py b/tire/carrigan.py new file mode 100644 index 000000000..f1f187165 --- /dev/null +++ b/tire/carrigan.py @@ -0,0 +1,19 @@ +from tire.Tire import Tire + + +class Carrigan(Tire): + + def __init__(self, arr): + self.arr = arr + + def needs_service(self): + for wheel in self.arr: + if wheel >= 0.9: + return True + + return False + + +if __name__ == "__main__": + c = Carrigan([0.1, 0, 0.89, 1]) + print(c.needs_service()) \ No newline at end of file diff --git a/tire/octoprime.py b/tire/octoprime.py new file mode 100644 index 000000000..dd57728de --- /dev/null +++ b/tire/octoprime.py @@ -0,0 +1,22 @@ +from tire.Tire import Tire + + +class Octoprime(Tire): + + def __init__(self, arr): + self.arr = arr + + def needs_service(self): + sum = 0 + for wheel in self.arr: + sum += wheel + + if sum >= 3: + return True + else: + return False + + +if __name__ == "__main__": + c = Octoprime([1, 0, 1, 1]) + print(c.needs_service()) \ No newline at end of file