From 4956bf0b9a5d22d96ebb8e325bc0d604fcbde0db Mon Sep 17 00:00:00 2001 From: matthew-keicher <108882364+matthew-keicher@users.noreply.github.com> Date: Sat, 4 Nov 2023 19:00:44 -0400 Subject: [PATCH 1/3] Task 2 Refactoring -Created battery package -Created engine package -Modified car file -Created car factory --- battery/__init__.py | 0 battery/battery.py | 4 ++++ battery/nubbin_battery.py | 13 +++++++++++++ battery/spindler_battery.py | 13 +++++++++++++ car.py | 10 ---------- engine/capulet_engine.py | 6 ++---- engine/engine.py | 5 +++++ engine/sternman_engine.py | 6 ++---- engine/willoughby_engine.py | 6 +++--- test/car.py | 10 ++++++++++ test/car_factory.py | 38 +++++++++++++++++++++++++++++++++++++ test/serviceable.py | 0 12 files changed, 90 insertions(+), 21 deletions(-) create mode 100644 battery/__init__.py create mode 100644 battery/battery.py create mode 100644 battery/nubbin_battery.py create mode 100644 battery/spindler_battery.py delete mode 100644 car.py create mode 100644 engine/engine.py create mode 100644 test/car.py create mode 100644 test/car_factory.py create mode 100644 test/serviceable.py diff --git a/battery/__init__.py b/battery/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/battery/battery.py b/battery/battery.py new file mode 100644 index 000000000..19509ef52 --- /dev/null +++ b/battery/battery.py @@ -0,0 +1,4 @@ +from abc import ABC +class Battery(ABC): + def needs_service(self): + pass \ No newline at end of file diff --git a/battery/nubbin_battery.py b/battery/nubbin_battery.py new file mode 100644 index 000000000..ebdae9b6a --- /dev/null +++ b/battery/nubbin_battery.py @@ -0,0 +1,13 @@ +from battery.battery import Battery + +class NubbinBattery(Battery): + def __init__(self, current_date, last_service_date): + self.current_date = current_date + self.last_service_date = last_service_date + + def needs_service(self): + date_to_be_serviced_by = self.last_service_date + 4 + if date_to_be_serviced_by < self.current_date: + return True + else: + return False \ No newline at end of file diff --git a/battery/spindler_battery.py b/battery/spindler_battery.py new file mode 100644 index 000000000..b745171c7 --- /dev/null +++ b/battery/spindler_battery.py @@ -0,0 +1,13 @@ +from battery.battery import Battery + +class SpindlerBattery(Battery): + def __init__(self, current_date, last_service_date): + self.current_date = current_date + self.last_service_date = last_service_date + + def needs_service(self): + date_to_be_serviced_by = self.last_service_date + 4 + if date_to_be_serviced_by < self.current_date: + return True + else: + return False \ No newline at end of file diff --git a/car.py b/car.py deleted file mode 100644 index f7b980a1b..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): - pass diff --git a/engine/capulet_engine.py b/engine/capulet_engine.py index 69a2f3319..015fbee6b 100644 --- a/engine/capulet_engine.py +++ b/engine/capulet_engine.py @@ -1,9 +1,7 @@ -from abc import ABC +from engine.engine import Engine -from car import Car - -class CapuletEngine(Car, ABC): +class CapuletEngine(Engine): def __init__(self, last_service_date, current_mileage, last_service_mileage): super().__init__(last_service_date) self.current_mileage = current_mileage diff --git a/engine/engine.py b/engine/engine.py new file mode 100644 index 000000000..f16673d09 --- /dev/null +++ b/engine/engine.py @@ -0,0 +1,5 @@ +from abc import ABC + +class Engine(ABC): + def needs_service(self): + pass \ No newline at end of file diff --git a/engine/sternman_engine.py b/engine/sternman_engine.py index 72d8b5ab3..8409a7b8a 100644 --- a/engine/sternman_engine.py +++ b/engine/sternman_engine.py @@ -1,9 +1,7 @@ -from abc import ABC +from engine.engine import Engine -from car import Car - -class SternmanEngine(Car, ABC): +class SternmanEngine(Engine): def __init__(self, last_service_date, warning_light_is_on): super().__init__(last_service_date) self.warning_light_is_on = warning_light_is_on diff --git a/engine/willoughby_engine.py b/engine/willoughby_engine.py index e5e0dc581..6ed8682e5 100644 --- a/engine/willoughby_engine.py +++ b/engine/willoughby_engine.py @@ -1,9 +1,9 @@ -from abc import ABC +from engine.engine import Engine -from car import Car +from test.car import Car -class WilloughbyEngine(Car, ABC): +class WilloughbyEngine(Engine): def __init__(self, last_service_date, current_mileage, last_service_mileage): super().__init__(last_service_date) self.current_mileage = current_mileage diff --git a/test/car.py b/test/car.py new file mode 100644 index 000000000..4c28da4bc --- /dev/null +++ b/test/car.py @@ -0,0 +1,10 @@ +from abc import ABC, abstractmethod + + +class Car(ABC): + def __init__(self, engine, battery): + self.engine = engine + self.battery = battery + + def needs_service(self): + return self.engine.needs_service() or self.battery.needs_service() diff --git a/test/car_factory.py b/test/car_factory.py new file mode 100644 index 000000000..2b452319a --- /dev/null +++ b/test/car_factory.py @@ -0,0 +1,38 @@ +from battery.nubbin_battery import NubbinBattery +from battery.spindler_battery import SpindlerBattery +from engine.capulet_engine import CapuletEngine +from engine.sternman_engine import SternmanEngine +from engine.willoughby_engine import WilloughbyEngine +from test.car import Car + + +class CarFactory: + def create_calliope(current_date, last_service_date, current_mileage, last_service_mileage): + engine = CapuletEngine(current_mileage, last_service_mileage) + battery = SpindlerBattery(current_date, last_service_date) + car = Car(engine, battery) + return car + + def create_palindrome(current_date, last_service_date, current_mileage, last_service_mileage): + engine = SternmanEngine(current_mileage, last_service_mileage) + battery = SpindlerBattery(current_date, last_service_date) + car = Car(engine, battery) + return car + + def create_glissade(current_date, last_service_date, current_mileage, last_service_mileage): + engine = WilloughbyEngine(current_mileage, last_service_mileage) + battery = SpindlerBattery(current_date, last_service_date) + car = Car(engine, battery) + return car + + def create_rorschach(current_date, last_service_date, current_mileage, last_service_mileage): + engine = WilloughbyEngine(current_mileage, last_service_mileage) + battery = NubbinBattery(current_date, last_service_date) + car = Car(engine, battery) + return car + + def create_thovex(current_date, last_service_date, current_mileage, last_service_mileage): + engine = CapuletEngine(current_mileage, last_service_mileage) + battery = NubbinBattery(current_date, last_service_date) + car = Car(engine, battery) + return car \ No newline at end of file diff --git a/test/serviceable.py b/test/serviceable.py new file mode 100644 index 000000000..e69de29bb From 2424e14392e86ff76b474bb92aaa16b9588f6263 Mon Sep 17 00:00:00 2001 From: matthew-keicher <108882364+matthew-keicher@users.noreply.github.com> Date: Sat, 4 Nov 2023 20:00:04 -0400 Subject: [PATCH 2/3] Task 3 -Edited files to be more like ideal answer -Created unit tests for batteries and engines --- battery/nubbin_battery.py | 6 +- battery/spindler_battery.py | 6 +- engine/capulet_engine.py | 7 +- engine/sternman_engine.py | 7 +- engine/willoughby_engine.py | 9 +- test/car.py | 6 +- test/serviceable.py | 7 ++ test/test_batteries.py | 31 ++++++ test/test_car.py | 188 ------------------------------------ test/test_engines.py | 45 +++++++++ test/util.py | 3 + 11 files changed, 106 insertions(+), 209 deletions(-) create mode 100644 test/test_batteries.py delete mode 100644 test/test_car.py create mode 100644 test/test_engines.py create mode 100644 test/util.py diff --git a/battery/nubbin_battery.py b/battery/nubbin_battery.py index ebdae9b6a..f09e8c1ee 100644 --- a/battery/nubbin_battery.py +++ b/battery/nubbin_battery.py @@ -1,4 +1,6 @@ from battery.battery import Battery +from test.util import add_years_to_date + class NubbinBattery(Battery): def __init__(self, current_date, last_service_date): @@ -6,8 +8,8 @@ def __init__(self, current_date, last_service_date): self.last_service_date = last_service_date def needs_service(self): - date_to_be_serviced_by = self.last_service_date + 4 - if date_to_be_serviced_by < self.current_date: + date_which_battery_should_be_serviced_by = add_years_to_date(self.last_service_date, 4) + if date_which_battery_should_be_serviced_by < self.current_date: return True else: return False \ No newline at end of file diff --git a/battery/spindler_battery.py b/battery/spindler_battery.py index b745171c7..853331909 100644 --- a/battery/spindler_battery.py +++ b/battery/spindler_battery.py @@ -1,4 +1,6 @@ from battery.battery import Battery +from test.util import add_years_to_date + class SpindlerBattery(Battery): def __init__(self, current_date, last_service_date): @@ -6,8 +8,8 @@ def __init__(self, current_date, last_service_date): self.last_service_date = last_service_date def needs_service(self): - date_to_be_serviced_by = self.last_service_date + 4 - if date_to_be_serviced_by < self.current_date: + date_which_battery_should_be_serviced_by = add_years_to_date(self.last_service_date, 2) + if date_which_battery_should_be_serviced_by < self.current_date: return True else: return False \ No newline at end of file diff --git a/engine/capulet_engine.py b/engine/capulet_engine.py index 015fbee6b..2fc043d17 100644 --- a/engine/capulet_engine.py +++ b/engine/capulet_engine.py @@ -2,10 +2,9 @@ class CapuletEngine(Engine): - def __init__(self, last_service_date, current_mileage, last_service_mileage): - super().__init__(last_service_date) + def __init__(self, current_mileage, last_service_mileage): self.current_mileage = current_mileage self.last_service_mileage = last_service_mileage - def engine_should_be_serviced(self): - return self.current_mileage - self.last_service_mileage > 30000 + def needs_service(self): + return self.current_mileage - self.last_service_mileage > 30000 \ No newline at end of file diff --git a/engine/sternman_engine.py b/engine/sternman_engine.py index 8409a7b8a..e002c9274 100644 --- a/engine/sternman_engine.py +++ b/engine/sternman_engine.py @@ -2,12 +2,11 @@ class SternmanEngine(Engine): - def __init__(self, last_service_date, warning_light_is_on): - super().__init__(last_service_date) + 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 + return False \ No newline at end of file diff --git a/engine/willoughby_engine.py b/engine/willoughby_engine.py index 6ed8682e5..adfe901ae 100644 --- a/engine/willoughby_engine.py +++ b/engine/willoughby_engine.py @@ -1,13 +1,10 @@ from engine.engine import Engine -from test.car import Car - class WilloughbyEngine(Engine): - def __init__(self, last_service_date, current_mileage, last_service_mileage): - super().__init__(last_service_date) + def __init__(self, current_mileage, last_service_mileage): self.current_mileage = current_mileage self.last_service_mileage = last_service_mileage - def engine_should_be_serviced(self): - return self.current_mileage - self.last_service_mileage > 60000 + def needs_service(self): + return self.current_mileage - self.last_service_mileage > 60000 \ No newline at end of file diff --git a/test/car.py b/test/car.py index 4c28da4bc..05cccb4da 100644 --- a/test/car.py +++ b/test/car.py @@ -1,10 +1,10 @@ -from abc import ABC, abstractmethod +from serviceable import Serviceable -class Car(ABC): +class Car(Serviceable): def __init__(self, engine, battery): self.engine = engine self.battery = battery def needs_service(self): - return self.engine.needs_service() or self.battery.needs_service() + return self.engine.needs_service() or self.battery.needs_service() \ No newline at end of file diff --git a/test/serviceable.py b/test/serviceable.py index e69de29bb..0ba86de2e 100644 --- a/test/serviceable.py +++ b/test/serviceable.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class Serviceable(ABC): + @abstractmethod + def needs_service(self): + pass \ No newline at end of file diff --git a/test/test_batteries.py b/test/test_batteries.py new file mode 100644 index 000000000..00fb08167 --- /dev/null +++ b/test/test_batteries.py @@ -0,0 +1,31 @@ +import unittest +from datetime import date + +from battery.nubbin_battery import NubbinBattery +from battery.spindler_battery import SpindlerBattery + +class TestNubbinBattery(unittest.TestCase): + def test_needs_service(self): + current_date = date.fromisoformat("2023-11-04") + last_service_date = date.fromisoformat("2018-11-04") + battery = NubbinBattery(current_date, last_service_date) + self.assertTrue(battery.needs_service()) + + def test_does_not_needs_service(self): + current_date = date.fromisoformat("2023-11-04") + last_service_date = date.fromisoformat("2022-11-04") + battery = NubbinBattery(current_date, last_service_date) + self.assertFalse(battery.needs_service()) + +class TestSpindlerBattery(unittest.TestCase): + def test_needs_service(self): + current_date = date.fromisoformat("2023-11-04") + last_service_date = date.fromisoformat("2015-11-04") + battery = SpindlerBattery(current_date, last_service_date) + self.assertTrue(battery.needs_service()) + + def test_does_not_needs_service(self): + current_date = date.fromisoformat("2023-11-04") + last_service_date = date.fromisoformat("2022-11-04") + battery = SpindlerBattery(current_date, last_service_date) + self.assertFalse(battery.needs_service()) \ No newline at end of file diff --git a/test/test_car.py b/test/test_car.py deleted file mode 100644 index f5994670d..000000000 --- a/test/test_car.py +++ /dev/null @@ -1,188 +0,0 @@ -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 - - -class TestCalliope(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - 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()) - - 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()) - - 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()) - - 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()) - - -class TestGlissade(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) - current_mileage = 0 - last_service_mileage = 0 - - car = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(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 = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(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()) - - 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()) - - -class TestPalindrome(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - 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()) - - def test_battery_should_not_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) - warning_light_is_on = False - - car = Palindrome(last_service_date, warning_light_is_on) - self.assertFalse(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()) - - 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()) - - -class TestRorschach(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 5) - current_mileage = 0 - last_service_mileage = 0 - - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_battery_should_not_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) - current_mileage = 0 - last_service_mileage = 0 - - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(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()) - - 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()) - - -class TestThovex(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 5) - current_mileage = 0 - last_service_mileage = 0 - - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_battery_should_not_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) - current_mileage = 0 - last_service_mileage = 0 - - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(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()) - - 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()) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_engines.py b/test/test_engines.py new file mode 100644 index 000000000..9fcdf8d2d --- /dev/null +++ b/test/test_engines.py @@ -0,0 +1,45 @@ +import unittest + +from engine.capulet_engine import CapuletEngine +from engine.willoughby_engine import WilloughbyEngine +from engine.sternman_engine import SternmanEngine + + +class TestCapuletEngine(unittest.TestCase): + def test_needs_service(self): + current_mileage = 30001 + last_service_mileage = 0 + engine = CapuletEngine(current_mileage, last_service_mileage) + self.assertTrue(engine.needs_service()) + + def test_does_not_needs_service(self): + current_mileage = 30000 + last_service_mileage = 0 + engine = CapuletEngine(current_mileage, last_service_mileage) + self.assertFalse(engine.needs_service()) + + +class TestWilloughbyEngine(unittest.TestCase): + def test_needs_service(self): + current_mileage = 60001 + last_service_mileage = 0 + engine = WilloughbyEngine(current_mileage, last_service_mileage) + self.assertTrue(engine.needs_service()) + + def test_does_not_needs_service(self): + current_mileage = 60000 + last_service_mileage = 0 + engine = WilloughbyEngine(current_mileage, last_service_mileage) + self.assertFalse(engine.needs_service()) + + +class TestSternmanEngine(unittest.TestCase): + def test_needs_service(self): + warning_light_is_on = True + engine = SternmanEngine(warning_light_is_on) + self.assertTrue(engine.needs_service()) + + def test_does_not_needs_service(self): + warning_light_is_on = False + engine = SternmanEngine(warning_light_is_on) + self.assertFalse(engine.needs_service()) diff --git a/test/util.py b/test/util.py new file mode 100644 index 000000000..1f5616d7f --- /dev/null +++ b/test/util.py @@ -0,0 +1,3 @@ +def add_years_to_date(original_date, years_to_add): + result = original_date.replace(year=original_date.year + years_to_add) + return result \ No newline at end of file From a4e467ead8e207501944de119a1a1665d8288d8e Mon Sep 17 00:00:00 2001 From: matthew-keicher <108882364+matthew-keicher@users.noreply.github.com> Date: Sat, 4 Nov 2023 21:24:08 -0400 Subject: [PATCH 3/3] Task 4 -Upgraded Spindler battery -Created tire package -Create unit tests for tires --- battery/spindler_battery.py | 2 +- test/test_tires.py | 26 ++++++++++++++++++++++++++ tires/__init__.py | 0 tires/carrigan_tires.py | 11 +++++++++++ tires/octoprime_tires.py | 8 ++++++++ tires/tires.py | 5 +++++ 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 test/test_tires.py create mode 100644 tires/__init__.py create mode 100644 tires/carrigan_tires.py create mode 100644 tires/octoprime_tires.py create mode 100644 tires/tires.py diff --git a/battery/spindler_battery.py b/battery/spindler_battery.py index 853331909..39e60655e 100644 --- a/battery/spindler_battery.py +++ b/battery/spindler_battery.py @@ -8,7 +8,7 @@ def __init__(self, current_date, last_service_date): self.last_service_date = last_service_date def needs_service(self): - date_which_battery_should_be_serviced_by = add_years_to_date(self.last_service_date, 2) + date_which_battery_should_be_serviced_by = add_years_to_date(self.last_service_date, 3) if date_which_battery_should_be_serviced_by < self.current_date: return True else: diff --git a/test/test_tires.py b/test/test_tires.py new file mode 100644 index 000000000..e9011fe4a --- /dev/null +++ b/test/test_tires.py @@ -0,0 +1,26 @@ +import unittest + +from tires.carrigan_tires import CarriganTires +from tires.octoprime_tires import OctoprimeTires + +class TestCarriganTires(unittest.TestCase): + def test_needs_service_true(self): + tire_wear = [0.1, 0.3, 0.2, 0.9] + tires = CarriganTires(tire_wear) + self.assertTrue(tires.needs_service()) + + def test_needs_service_false(self): + tire_wear = [0.1, 0.2, 0.4, 0.2] + tires = CarriganTires(tire_wear) + self.assertFalse(tires.needs_service()) + +class TestOctoprimeTires(unittest.TestCase): + def test_needs_service_true(self): + tire_wear = [0.8, 0.8, 0.8, 0.7] + tires = OctoprimeTires(tire_wear) + self.assertTrue(tires.needs_service()) + + def test_needs_service_false(self): + tire_wear = [0.1, 0.2, 0.4, 0.2] + tires = OctoprimeTires(tire_wear) + self.assertFalse(tires.needs_service()) \ No newline at end of file diff --git a/tires/__init__.py b/tires/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tires/carrigan_tires.py b/tires/carrigan_tires.py new file mode 100644 index 000000000..bb8100cf0 --- /dev/null +++ b/tires/carrigan_tires.py @@ -0,0 +1,11 @@ +from tires.tires import Tires + +class CarriganTires(Tires): + def __init__(self, tire_wear): + self.tire_wear = tire_wear + + def needs_service(self): + for tire in self.tire_wear: + if tire >= 0.9: + return True + return False \ No newline at end of file diff --git a/tires/octoprime_tires.py b/tires/octoprime_tires.py new file mode 100644 index 000000000..bc75852e7 --- /dev/null +++ b/tires/octoprime_tires.py @@ -0,0 +1,8 @@ +from tires.tires import Tires + +class OctoprimeTires(Tires): + def __init__(self, tire_wear): + self.tire_wear = tire_wear + + def needs_service(self): + return sum(self.tire_wear) >= 3.0 \ No newline at end of file diff --git a/tires/tires.py b/tires/tires.py new file mode 100644 index 000000000..35bbbeab3 --- /dev/null +++ b/tires/tires.py @@ -0,0 +1,5 @@ +from abc import ABC + +class Tires(ABC): + def needs_service(self): + pass \ No newline at end of file