Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task 2 #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions battery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from abc import ABC, abstractmethod

class Battery(ABC):
def __init__(self):
pass

@abstractmethod
def needs_service(self):
pass
15 changes: 15 additions & 0 deletions battery/nubbinBattery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from abc import ABC
from battery import Battery
from datetime import datetime

class NubbinBattery(Battery, ABC):
def __init__(self, last_service_date, current_date):
self.last_service_date = last_service_date
self.current_date = current_date
self.batteryServiceYears = 4

def needs_service(self):
if self.last_service_date - self.current_date < self.batteryServiceYears:
return True
else:
return False
16 changes: 16 additions & 0 deletions battery/spindlerBattery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from abc import ABC
from battery import Battery
from datetime import datetime

class SpindlerBattery(Battery, ABC):

def __init__(self, last_service_date, current_date):
self.last_service_date = last_service_date
self.current_date = current_date
self.batteryServiceYears = 2

def needs_service(self):
if self.last_service_date - self.current_date < self.batteryServiceYears:
return True
else:
return False
8 changes: 5 additions & 3 deletions car.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from abc import ABC, abstractmethod

from engine import Engine
from battery import Battery

class Car(ABC):
def __init__(self, last_service_date):
self.last_service_date = last_service_date
def __init__(self, engine, battery):
self.engine = engine
self.battery = battery

@abstractmethod
def needs_service(self):
Expand Down
15 changes: 9 additions & 6 deletions engine/capulet_engine.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from abc import ABC
from engine import Engine

from car import Car


class CapuletEngine(Car, ABC):
class CapuletEngine(Engine, ABC):
def __init__(self, last_service_date, current_mileage, last_service_mileage):
super().__init__(last_service_date)
self.service_miles = 30000
self.current_mileage = current_mileage
self.last_service_mileage = last_service_mileage
self.service_miles = service_miles

def engine_should_be_serviced(self):
return self.current_mileage - self.last_service_mileage > 30000
def needs_service(self):
if self.current_mileage - self.last_service_mileage < service_miles:
return True
else:
return False
10 changes: 10 additions & 0 deletions engine/engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from abc import ABC, abstractmethod


class Engine(ABC):
def __init__(self):
pass

@abstractmethod
def needs_service(self):
pass
15 changes: 8 additions & 7 deletions engine/model/calliope.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from datetime import datetime

from engine.capulet_engine import CapuletEngine
from battery.spindlerBattery import SpindlerBattery
from car import Car

class Calliope(Car):

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
def __init(self, last_service_date, current_mileage):
super().__init__(last_service_date, current_mileage) # Call the constructors of parent classes
self.current_date = datetime.today().date()
self.engine = CapuletEngine (last_service_date, current_mileage)
self.battery = SpindlerBattery (last_service_date, self.current_date)
17 changes: 9 additions & 8 deletions engine/model/glissade.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from datetime import datetime

from engine.willoughby_engine import WilloughbyEngine
from battery.spindlerBattery import SpindlerBattery
from car import Car


class Glissade(Car):
def __init(self, last_service_date, current_mileage):
super().__init__(last_service_date, current_mileage) # Call the constructors of parent classes
self.current_date = datetime.today().date()
self.engine = WilloughbyEngine(last_service_date, current_mileage)
self.battery = SpindlerBattery (last_service_date, self.current_date)

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
14 changes: 7 additions & 7 deletions engine/model/palindrome.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from datetime import datetime

from battery.spindlerBattery import SpindlerBattery
from car import Car
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
def __init(self, last_service_date, current_mileage):
super().__init__(last_service_date, current_mileage) # Call the constructors of parent classes
self.current_date = datetime.today().date()
self.engine = SternmanEngine(last_service_date, current_mileage)
self.battery = SpindlerBattery (last_service_date, self.current_date)
9 changes: 8 additions & 1 deletion engine/model/rorschach.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from datetime import datetime

from battery.nubbinBattery import NubbinBattery
from car import Car
from engine.willoughby_engine import WilloughbyEngine


class Rorschach(WilloughbyEngine):
def __init(self, last_service_date, current_mileage):
super().__init__(last_service_date, current_mileage) # Call the constructors of parent classes
self.current_date = datetime.today().date()
self.engine = WilloughbyEngine(last_service_date, current_mileage)
self.battery = NubbinBattery (last_service_date, self.current_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() or self.engine_should_be_serviced():
Expand Down
9 changes: 8 additions & 1 deletion engine/model/thovex.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from datetime import datetime

from battery.nubbinBattery import NubbinBattery
from car import Car
from engine.capulet_engine import CapuletEngine


class Thovex(CapuletEngine):
def __init(self, last_service_date, current_mileage):
super().__init__(last_service_date, current_mileage) # Call the constructors of parent classes
self.current_date = datetime.today().date()
self.engine = CapuletEngine(last_service_date, current_mileage)
self.battery = NubbinBattery (last_service_date, self.current_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() or self.engine_should_be_serviced():
Expand Down
16 changes: 8 additions & 8 deletions engine/sternman_engine.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from abc import ABC
from engine import Engine

from car import Car


class SternmanEngine(Car, ABC):
def __init__(self, last_service_date, warning_light_is_on):
class SternmanEngine(Engine, ABC):
def __init__(self, last_service_date, current_mileage, last_service_mileage):
super().__init__(last_service_date)
self.warning_light_is_on = warning_light_is_on
self.current_mileage = current_mileage
self.last_service_mileage = last_service_mileage
self.isWarningLightOn = False

def engine_should_be_serviced(self):
if self.warning_light_is_on:
def needs_service(self):
if self.isWarningLightOn == True:
return True
else:
return False
15 changes: 9 additions & 6 deletions engine/willoughby_engine.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from abc import ABC
from engine import Engine

from car import Car


class WilloughbyEngine(Car, ABC):
def __init__(self, last_service_date, current_mileage, last_service_mileage):
class WilloughbyEngine(Engine, ABC):
def __init__(self, last_service_date, current_mileage, last_service_mileage, service_miles):
super().__init__(last_service_date)
self.current_mileage = current_mileage
self.last_service_mileage = last_service_mileage
self.service_miles = service_miles

def engine_should_be_serviced(self):
return self.current_mileage - self.last_service_mileage > 60000
def needs_service(self):
if self.current_mileage - self.last_service_mileage < service_miles:
return True
else:
return False