From 8d2ffa6eafadd59b340741cbd18142411fe648bc Mon Sep 17 00:00:00 2001 From: anmol choudhary <78426956+Anmol-Choudhary-26@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:46:11 +0530 Subject: [PATCH 1/5] Update README.md --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b5ae3b21..dba26dd5f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,41 @@ -# Starter Repo -This repo has everything you need to get started on the program, good luck! +# Forage: Discover the Perfect Lyft Rental + +![forage](./app/assets/images/forage_logo.png) + +Welcome to Forage, a mobile app that connects users with the perfect Lyft rental vehicle for their specific needs. Whether you're in need of a luxury car, an electric vehicle, or simply prefer a specific brand, Forage has you covered. + +## Table of Contents + +1. [Getting Started](#getting-started) +2. [Features](#features) +3. [Contributing](#contributing) +4. [License](#license) + +## Getting Started + +These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. + +### Prerequisites + +To install and run Forage, you will need the following: + +- [Node.js](https://nodejs.org/en/) (version 10.x or higher) +- [Yarn](https://yarnpkg.com/en/) (version 1.x or higher) +- A [Firebase](https://firebase.google.com/) account and project +- A [Lyft API](https://www.lyft.com/developers) account and API key + +### InstallationContributing + +1. Clone the repository: +git clone https://github.com/Anmol-Choudhary-26/forage-lyft-Rental.git +cd forage-lyft-Rental +npm install +npm start + +### Contributing +We welcome contributions from the community! If you'd like to contribute to the Forage Lyft Rental App, please follow these guidelines: + +Fork the repository and create a new branch for your feature or bug fix. +Make your changes and ensure the codebase adheres to the project's coding standards. +Submit a pull request detailing the changes you've made and any relevant information about the update. + From 5d00ad20f04c2904b814b781ca5caa18cdaeca85 Mon Sep 17 00:00:00 2001 From: anmol choudhary <78426956+Anmol-Choudhary-26@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:46:33 +0530 Subject: [PATCH 2/5] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index dba26dd5f..f77386017 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,11 @@ To install and run Forage, you will need the following: 1. Clone the repository: git clone https://github.com/Anmol-Choudhary-26/forage-lyft-Rental.git + cd forage-lyft-Rental + npm install + npm start ### Contributing From 060a2e35998bd6fa3f43ae9cfd1f6b37610304c5 Mon Sep 17 00:00:00 2001 From: anmol choudhary <78426956+Anmol-Choudhary-26@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:47:08 +0530 Subject: [PATCH 3/5] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f77386017..7d7309868 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,11 @@ To install and run Forage, you will need the following: 1. Clone the repository: git clone https://github.com/Anmol-Choudhary-26/forage-lyft-Rental.git -cd forage-lyft-Rental +2. cd forage-lyft-Rental -npm install +3. npm install -npm start +4. npm start ### Contributing We welcome contributions from the community! If you'd like to contribute to the Forage Lyft Rental App, please follow these guidelines: From db76fbdef1d68f1a98951ef9d9b673a53dd90d1a Mon Sep 17 00:00:00 2001 From: Anmol Choudhary Date: Mon, 16 Oct 2023 22:05:31 +0530 Subject: [PATCH 4/5] updated --- README.md | 45 +------------------ __init__.py | 0 battery/__init__.py | 0 battery/battery.py | 6 +++ battery/nubbin_battery.py | 15 +++++++ battery/spindler_battery.py | 15 +++++++ car.py | 13 +++--- car_factory.py | 50 ++++++++++++++++++++++ engine/capulet_engine.py | 11 ++--- engine/engine.py | 6 +++ engine/sternman_engine.py | 11 ++--- engine/willoughby_engine.py | 11 ++--- serviceable.py | 7 +++ test/test_battery/__init__.py | 0 test/test_battery/test_nubbin_battery.py | 18 ++++++++ test/test_battery/test_spindler_battery.py | 18 ++++++++ test/test_engine/__init__.py | 0 test/test_engine/test_capulet_engine.py | 17 ++++++++ test/test_engine/test_sternman_engine.py | 15 +++++++ test/test_engine/test_willoughby_engine.py | 17 ++++++++ test/test_tires/__init__.py | 0 test/test_tires/test_carrigan_tires.py | 15 +++++++ test/test_tires/test_octoprime_tires.py | 15 +++++++ tires/__init__.py | 0 tires/carrigan_tires.py | 12 ++++++ tires/octoprime_tires.py | 9 ++++ tires/tires.py | 6 +++ utils.py | 3 ++ 28 files changed, 264 insertions(+), 71 deletions(-) create mode 100644 __init__.py 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 create mode 100644 car_factory.py create mode 100644 engine/engine.py create mode 100644 serviceable.py create mode 100644 test/test_battery/__init__.py create mode 100644 test/test_battery/test_nubbin_battery.py create mode 100644 test/test_battery/test_spindler_battery.py create mode 100644 test/test_engine/__init__.py create mode 100644 test/test_engine/test_capulet_engine.py create mode 100644 test/test_engine/test_sternman_engine.py create mode 100644 test/test_engine/test_willoughby_engine.py create mode 100644 test/test_tires/__init__.py create mode 100644 test/test_tires/test_carrigan_tires.py create mode 100644 test/test_tires/test_octoprime_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 create mode 100644 utils.py diff --git a/README.md b/README.md index 7d7309868..982632154 100644 --- a/README.md +++ b/README.md @@ -1,44 +1 @@ -# Forage: Discover the Perfect Lyft Rental - -![forage](./app/assets/images/forage_logo.png) - -Welcome to Forage, a mobile app that connects users with the perfect Lyft rental vehicle for their specific needs. Whether you're in need of a luxury car, an electric vehicle, or simply prefer a specific brand, Forage has you covered. - -## Table of Contents - -1. [Getting Started](#getting-started) -2. [Features](#features) -3. [Contributing](#contributing) -4. [License](#license) - -## Getting Started - -These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. - -### Prerequisites - -To install and run Forage, you will need the following: - -- [Node.js](https://nodejs.org/en/) (version 10.x or higher) -- [Yarn](https://yarnpkg.com/en/) (version 1.x or higher) -- A [Firebase](https://firebase.google.com/) account and project -- A [Lyft API](https://www.lyft.com/developers) account and API key - -### InstallationContributing - -1. Clone the repository: -git clone https://github.com/Anmol-Choudhary-26/forage-lyft-Rental.git - -2. cd forage-lyft-Rental - -3. npm install - -4. npm start - -### Contributing -We welcome contributions from the community! If you'd like to contribute to the Forage Lyft Rental App, please follow these guidelines: - -Fork the repository and create a new branch for your feature or bug fix. -Make your changes and ensure the codebase adheres to the project's coding standards. -Submit a pull request detailing the changes you've made and any relevant information about the update. - +# Task 4 model answer diff --git a/__init__.py b/__init__.py new file mode 100644 index 000000000..e69de29bb 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..a20370d9c --- /dev/null +++ b/battery/battery.py @@ -0,0 +1,6 @@ +from abc import ABC + + +class Battery(ABC): + def needs_service(self): + pass diff --git a/battery/nubbin_battery.py b/battery/nubbin_battery.py new file mode 100644 index 000000000..a0301568e --- /dev/null +++ b/battery/nubbin_battery.py @@ -0,0 +1,15 @@ +from battery.battery import Battery +from utils import add_years_to_date + + +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_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 diff --git a/battery/spindler_battery.py b/battery/spindler_battery.py new file mode 100644 index 000000000..aaa961672 --- /dev/null +++ b/battery/spindler_battery.py @@ -0,0 +1,15 @@ +from battery.battery import Battery +from utils import add_years_to_date + + +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_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: + return False diff --git a/car.py b/car.py index f7b980a1b..404b4914d 100644 --- a/car.py +++ b/car.py @@ -1,10 +1,11 @@ -from abc import ABC, abstractmethod +from serviceable import Serviceable -class Car(ABC): - def __init__(self, last_service_date): - self.last_service_date = last_service_date +class Car(Serviceable): + def __init__(self, engine, battery, tires): + self.engine = engine + self.battery = battery + self.tires = tires - @abstractmethod def needs_service(self): - pass + return self.engine.needs_service() or self.battery.needs_service() or self.tires.needs_service() diff --git a/car_factory.py b/car_factory.py new file mode 100644 index 000000000..5e584979a --- /dev/null +++ b/car_factory.py @@ -0,0 +1,50 @@ +from battery.nubbin_battery import NubbinBattery +from battery.spindler_battery import SpindlerBattery +from car import Car +from engine.capulet_engine import CapuletEngine +from engine.sternman_engine import SternmanEngine +from engine.willoughby_engine import WilloughbyEngine +from tires.carrigan_tires import CarriganTires +from tires.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 diff --git a/engine/capulet_engine.py b/engine/capulet_engine.py index 69a2f3319..b6de99d9d 100644 --- a/engine/capulet_engine.py +++ b/engine/capulet_engine.py @@ -1,13 +1,10 @@ -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) +class CapuletEngine(Engine): + 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): + def needs_service(self): return self.current_mileage - self.last_service_mileage > 30000 diff --git a/engine/engine.py b/engine/engine.py new file mode 100644 index 000000000..585a3dd0d --- /dev/null +++ b/engine/engine.py @@ -0,0 +1,6 @@ +from abc import ABC + + +class Engine(ABC): + def needs_service(self): + pass diff --git a/engine/sternman_engine.py b/engine/sternman_engine.py index 72d8b5ab3..7b36ce5ef 100644 --- a/engine/sternman_engine.py +++ b/engine/sternman_engine.py @@ -1,14 +1,11 @@ -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: diff --git a/engine/willoughby_engine.py b/engine/willoughby_engine.py index e5e0dc581..aacc37340 100644 --- a/engine/willoughby_engine.py +++ b/engine/willoughby_engine.py @@ -1,13 +1,10 @@ -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) +class WilloughbyEngine(Engine): + 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): + def needs_service(self): return self.current_mileage - self.last_service_mileage > 60000 diff --git a/serviceable.py b/serviceable.py new file mode 100644 index 000000000..701fa1e66 --- /dev/null +++ b/serviceable.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class Serviceable(ABC): + @abstractmethod + def needs_service(self): + pass diff --git a/test/test_battery/__init__.py b/test/test_battery/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_battery/test_nubbin_battery.py b/test/test_battery/test_nubbin_battery.py new file mode 100644 index 000000000..3f00cd455 --- /dev/null +++ b/test/test_battery/test_nubbin_battery.py @@ -0,0 +1,18 @@ +import unittest +from datetime import date + +from battery.nubbin_battery import NubbinBattery + + +class TestNubbinBattery(unittest.TestCase): + def test_needs_service_true(self): + current_date = date.fromisoformat("2020-05-15") + last_service_date = date.fromisoformat("2016-01-25") + battery = NubbinBattery(current_date, last_service_date) + self.assertTrue(battery.needs_service()) + + def test_needs_service_false(self): + current_date = date.fromisoformat("2020-05-15") + last_service_date = date.fromisoformat("2019-01-10") + battery = NubbinBattery(current_date, last_service_date) + self.assertFalse(battery.needs_service()) diff --git a/test/test_battery/test_spindler_battery.py b/test/test_battery/test_spindler_battery.py new file mode 100644 index 000000000..3f811da78 --- /dev/null +++ b/test/test_battery/test_spindler_battery.py @@ -0,0 +1,18 @@ +import unittest +from datetime import date + +from battery.spindler_battery import SpindlerBattery + + +class TestSpindlerBattery(unittest.TestCase): + def test_needs_service_true(self): + current_date = date.fromisoformat("2020-05-15") + last_service_date = date.fromisoformat("2017-01-25") + battery = SpindlerBattery(current_date, last_service_date) + self.assertTrue(battery.needs_service()) + + def test_needs_service_false(self): + current_date = date.fromisoformat("2020-05-15") + last_service_date = date.fromisoformat("2019-01-10") + battery = SpindlerBattery(current_date, last_service_date) + self.assertFalse(battery.needs_service()) diff --git a/test/test_engine/__init__.py b/test/test_engine/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_engine/test_capulet_engine.py b/test/test_engine/test_capulet_engine.py new file mode 100644 index 000000000..74e0c4791 --- /dev/null +++ b/test/test_engine/test_capulet_engine.py @@ -0,0 +1,17 @@ +import unittest + +from engine.capulet_engine import CapuletEngine + + +class TestCapuletEngine(unittest.TestCase): + def test_needs_service_true(self): + current_mileage = 30001 + last_service_mileage = 0 + engine = CapuletEngine(current_mileage, last_service_mileage) + self.assertTrue(engine.needs_service()) + + def test_needs_service_false(self): + current_mileage = 30000 + last_service_mileage = 0 + engine = CapuletEngine(current_mileage, last_service_mileage) + self.assertFalse(engine.needs_service()) diff --git a/test/test_engine/test_sternman_engine.py b/test/test_engine/test_sternman_engine.py new file mode 100644 index 000000000..769eb9a75 --- /dev/null +++ b/test/test_engine/test_sternman_engine.py @@ -0,0 +1,15 @@ +import unittest + +from engine.sternman_engine import SternmanEngine + + +class TestSternmanEngine(unittest.TestCase): + def test_needs_service_true(self): + warning_light_is_on = True + engine = SternmanEngine(warning_light_is_on) + self.assertTrue(engine.needs_service()) + + def test_needs_service_false(self): + warning_light_is_on = False + engine = SternmanEngine(warning_light_is_on) + self.assertFalse(engine.needs_service()) diff --git a/test/test_engine/test_willoughby_engine.py b/test/test_engine/test_willoughby_engine.py new file mode 100644 index 000000000..dad7f1705 --- /dev/null +++ b/test/test_engine/test_willoughby_engine.py @@ -0,0 +1,17 @@ +import unittest + +from engine.willoughby_engine import WilloughbyEngine + + +class TestWilloughbyEngine(unittest.TestCase): + def test_needs_service_true(self): + current_mileage = 60001 + last_service_mileage = 0 + engine = WilloughbyEngine(current_mileage, last_service_mileage) + self.assertTrue(engine.needs_service()) + + def test_needs_service_false(self): + current_mileage = 60000 + last_service_mileage = 0 + engine = WilloughbyEngine(current_mileage, last_service_mileage) + self.assertFalse(engine.needs_service()) diff --git a/test/test_tires/__init__.py b/test/test_tires/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_tires/test_carrigan_tires.py b/test/test_tires/test_carrigan_tires.py new file mode 100644 index 000000000..dca1cb91a --- /dev/null +++ b/test/test_tires/test_carrigan_tires.py @@ -0,0 +1,15 @@ +import unittest + +from tires.carrigan_tires import CarriganTires + + +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()) diff --git a/test/test_tires/test_octoprime_tires.py b/test/test_tires/test_octoprime_tires.py new file mode 100644 index 000000000..693eb2b34 --- /dev/null +++ b/test/test_tires/test_octoprime_tires.py @@ -0,0 +1,15 @@ +import unittest + +from tires.octoprime_tires import OctoprimeTires + + +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()) 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..39b0d90c1 --- /dev/null +++ b/tires/carrigan_tires.py @@ -0,0 +1,12 @@ +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 diff --git a/tires/octoprime_tires.py b/tires/octoprime_tires.py new file mode 100644 index 000000000..be77f79a3 --- /dev/null +++ b/tires/octoprime_tires.py @@ -0,0 +1,9 @@ +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 diff --git a/tires/tires.py b/tires/tires.py new file mode 100644 index 000000000..6de65a859 --- /dev/null +++ b/tires/tires.py @@ -0,0 +1,6 @@ +from abc import ABC + + +class Tires(ABC): + def needs_service(self): + pass diff --git a/utils.py b/utils.py new file mode 100644 index 000000000..35b1e47ef --- /dev/null +++ b/utils.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 From 7c1b9c52e43990ac7246275cc02665ef31071557 Mon Sep 17 00:00:00 2001 From: anmol choudhary <78426956+Anmol-Choudhary-26@users.noreply.github.com> Date: Mon, 16 Oct 2023 23:48:10 +0530 Subject: [PATCH 5/5] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 982632154..f5988fa69 100644 --- a/README.md +++ b/README.md @@ -1 +1,40 @@ -# Task 4 model answer +# Forage: Discover the Perfect Lyft Rental + +![forage](./app/assets/images/forage_logo.png) + +Welcome to Forage, a mobile app that connects users with the perfect Lyft rental vehicle for their specific needs. Whether you're in need of a luxury car, an electric vehicle, or simply prefer a specific brand, Forage has you covered. + +## Table of Contents + +1. [Getting Started](#getting-started) +2. [Features](#features) +3. [Contributing](#contributing) +4. [License](#license) + +## Getting Started + +These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. + +### Prerequisites + +To install and run Forage, you will need the following: + +- [Node.js](https://nodejs.org/en/) (version 10.x or higher) +- [Yarn](https://yarnpkg.com/en/) (version 1.x or higher) +- A [Firebase](https://firebase.google.com/) account and project +- A [Lyft API](https://www.lyft.com/developers) account and API key + +### InstallationContributing + +1. Clone the repository: +git clone https://github.com/Anmol-Choudhary-26/forage-lyft-Rental.git +cd forage-lyft-Rental +npm install +npm start + +### Contributing +We welcome contributions from the community! If you'd like to contribute to the Forage Lyft Rental App, please follow these guidelines: + +Fork the repository and create a new branch for your feature or bug fix. +Make your changes and ensure the codebase adheres to the project's coding standards. +Submit a pull request detailing the changes you've made and any relevant information about the update.