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

Completed project #119

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Starter Repo
This repo has everything you need to get started on the program, good luck!
# forage-lyft-starter-repo
Lyft starter repo
Binary file added UML diagram of project.pdf
Binary file not shown.
Empty file added __init__.py
Empty file.
Empty file added battery/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions battery/battery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from abc import ABC


class Battery(ABC):
def needs_service(self):
pass
Empty file.
15 changes: 15 additions & 0 deletions battery/battery_type/nubbin_battery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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
self.nubbin_year_need_service = 3

def needs_service(self):
date_need_service = self.last_service_date.replace(year=self.last_service_date.year + self.nubbin_year_need_service)
if date_need_service < self.current_date:
return True
else:
return False
15 changes: 15 additions & 0 deletions battery/battery_type/spindler_battery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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
self.spindler_year_need_service = 4

def needs_service(self):
date_need_service = self.last_service_date.replace(year=self.last_service_date.year + self.spinder_year_need_service)
if date_need_service < self.current_date:
return True
else:
return False
21 changes: 11 additions & 10 deletions car.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
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
from serviceable import Serviceable


class Car(Serviceable):
def __init__(self, engine, battery, tires):
self.engine = engine
self.battery = battery
self.tires = tires

def needs_service(self):
return self.engine.needs_service() or self.battery.needs_service() or self.tires.needs_service()
Empty file added car_factory/__init__.py
Empty file.
53 changes: 53 additions & 0 deletions car_factory/car_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from car import Car

from battery.battery_type.nubbin_battery import NubbinBattery
from battery.battery_type.spindler_battery import SpindlerBattery

from engine.engine_type.capulet_engine import CapuletEngine
from engine.engine_type.sternman_engine import SternmanEngine
from engine.engine_type.willoughby_engine import WilloughbyEngine

from tires.tires_type.carrigan_tires import CarriganTires
from tires.tires_type.octoprime_tires import OctoprimeTires


class CarFactory:
@staticmethod
def create_calliope(current_date, last_service_date, current_mileage, last_service_mileage, tire_wear):
engine = CapuletEngine(current_mileage, last_service_mileage)
battery = SpindlerBattery(current_date, last_service_date)
tires = CarriganTires(tire_wear)
car = Car(engine, battery, tires)
return car

@staticmethod
def create_glissade(current_date, last_service_date, current_mileage, last_service_mileage, tire_wear):
engine = WilloughbyEngine(current_mileage, last_service_mileage)
battery = SpindlerBattery(current_date, last_service_date)
tires = OctoprimeTires(tire_wear)
car = Car(engine, battery, tires)
return car

@staticmethod
def create_palindrome(current_date, last_service_date, warning_light_is_on, tire_wear):
engine = SternmanEngine(warning_light_is_on)
battery = SpindlerBattery(current_date, last_service_date)
tires = CarriganTires(tire_wear)
car = Car(engine, battery, tires)
return car

@staticmethod
def create_rorschach(current_date, last_service_date, current_mileage, last_service_mileage, tire_wear):
engine = WilloughbyEngine(current_mileage, last_service_mileage)
battery = NubbinBattery(current_date, last_service_date)
tires = OctoprimeTires(tire_wear)
car = Car(engine, battery, tires)
return car

@staticmethod
def create_thovex(current_date, last_service_date, current_mileage, last_service_mileage, tire_wear):
engine = CapuletEngine(current_mileage, last_service_mileage)
battery = NubbinBattery(current_date, last_service_date)
tires = CarriganTires(tire_wear)
car = Car(engine, battery, tires)
return car
26 changes: 13 additions & 13 deletions engine/capulet_engine.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from abc import ABC

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
self.last_service_mileage = last_service_mileage

def engine_should_be_serviced(self):
return self.current_mileage - self.last_service_mileage > 30000
from abc import ABC
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
self.last_service_mileage = last_service_mileage
def engine_should_be_serviced(self):
return self.current_mileage - self.last_service_mileage > 30000
6 changes: 6 additions & 0 deletions engine/engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from abc import ABC


class Engine(ABC):
def needs_service(self):
pass
Empty file added engine/engine_type/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions engine/engine_type/capulet_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from engine.engine import Engine


class CapuletEngine(Engine):
def __init__(self, current_mileage, last_service_mileage):
self.current_mileage = current_mileage
self.last_service_mileage = last_service_mileage
self.capulet_milage_need_service = 30000

def needs_service(self):
return self.current_mileage - self.last_service_mileage > self.capulet_milage_need_service
12 changes: 12 additions & 0 deletions engine/engine_type/sternman_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from engine.engine import Engine


class SternmanEngine(Engine):
def __init__(self, warning_light_is_on):
self.warning_light_is_on = warning_light_is_on

def needs_service(self):
if self.warning_light_is_on:
return True
else:
return False
11 changes: 11 additions & 0 deletions engine/engine_type/willoughby_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from engine.engine import Engine


class WilloughbyEngine(Engine):
def __init__(self, current_mileage, last_service_mileage):
self.current_mileage = current_mileage
self.last_service_mileage = last_service_mileage
self.willoughby_milage_need_service = 60000

def needs_service(self):
return self.current_mileage - self.last_service_mileage > self.willoughby_milage_need_service
24 changes: 12 additions & 12 deletions engine/model/calliope.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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
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
24 changes: 12 additions & 12 deletions engine/model/glissade.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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
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
24 changes: 12 additions & 12 deletions engine/model/palindrome.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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
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
24 changes: 12 additions & 12 deletions engine/model/rorschach.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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
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
24 changes: 12 additions & 12 deletions engine/model/thovex.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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
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
30 changes: 15 additions & 15 deletions engine/sternman_engine.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from abc import ABC

from car import Car


class SternmanEngine(Car, ABC):
def __init__(self, last_service_date, warning_light_is_on):
super().__init__(last_service_date)
self.warning_light_is_on = warning_light_is_on

def engine_should_be_serviced(self):
if self.warning_light_is_on:
return True
else:
return False
from abc import ABC
from car import Car
class SternmanEngine(Car, ABC):
def __init__(self, last_service_date, warning_light_is_on):
super().__init__(last_service_date)
self.warning_light_is_on = warning_light_is_on
def engine_should_be_serviced(self):
if self.warning_light_is_on:
return True
else:
return False
26 changes: 13 additions & 13 deletions engine/willoughby_engine.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from abc import ABC

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
self.last_service_mileage = last_service_mileage

def engine_should_be_serviced(self):
return self.current_mileage - self.last_service_mileage > 60000
from abc import ABC
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
self.last_service_mileage = last_service_mileage
def engine_should_be_serviced(self):
return self.current_mileage - self.last_service_mileage > 60000
7 changes: 7 additions & 0 deletions serviceable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from abc import ABC, abstractmethod


class Serviceable(ABC):
@abstractmethod
def needs_service(self):
pass
Loading