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 4 completed #122

Open
wants to merge 5 commits 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
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
# 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.
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
15 changes: 15 additions & 0 deletions battery/nubbin_battery.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions battery/spindler_battery.py
Original file line number Diff line number Diff line change
@@ -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
13 changes: 7 additions & 6 deletions car.py
Original file line number Diff line number Diff line change
@@ -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()
50 changes: 50 additions & 0 deletions car_factory.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 4 additions & 7 deletions engine/capulet_engine.py
Original file line number Diff line number Diff line change
@@ -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
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
11 changes: 4 additions & 7 deletions engine/sternman_engine.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
11 changes: 4 additions & 7 deletions engine/willoughby_engine.py
Original file line number Diff line number Diff line change
@@ -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
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
Empty file added test/test_battery/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions test/test_battery/test_nubbin_battery.py
Original file line number Diff line number Diff line change
@@ -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())
18 changes: 18 additions & 0 deletions test/test_battery/test_spindler_battery.py
Original file line number Diff line number Diff line change
@@ -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())
Empty file added test/test_engine/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions test/test_engine/test_capulet_engine.py
Original file line number Diff line number Diff line change
@@ -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())
15 changes: 15 additions & 0 deletions test/test_engine/test_sternman_engine.py
Original file line number Diff line number Diff line change
@@ -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())
17 changes: 17 additions & 0 deletions test/test_engine/test_willoughby_engine.py
Original file line number Diff line number Diff line change
@@ -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())
Empty file added test/test_tires/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions test/test_tires/test_carrigan_tires.py
Original file line number Diff line number Diff line change
@@ -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())
15 changes: 15 additions & 0 deletions test/test_tires/test_octoprime_tires.py
Original file line number Diff line number Diff line change
@@ -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())
Empty file added tires/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions tires/carrigan_tires.py
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tires/octoprime_tires.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tires/tires.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from abc import ABC


class Tires(ABC):
def needs_service(self):
pass
3 changes: 3 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
@@ -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