From d76c57b2948b1f1820e52d79bda62120d8df2f0a Mon Sep 17 00:00:00 2001 From: "sneha.shinde19" Date: Sat, 21 Jul 2018 22:26:45 -0400 Subject: [PATCH 1/3] vehicle and customer files --- dealership/customers.py | 18 +++++++++++++----- dealership/vehicles.py | 22 +++++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/dealership/customers.py b/dealership/customers.py index 266b955..54c7e66 100644 --- a/dealership/customers.py +++ b/dealership/customers.py @@ -1,11 +1,19 @@ class Person(object): - def __init__(self, first_name, last_name, email): - pass - + def __init__(self, first_name, last_name, email): + self.first_name = first_name + self.last_name = last_name + self.email = email + class Customer(Person): - pass + pass + + def is_employee(self): + return False class Employee(Person): - pass + DISCOUNT = 10 + + def is_employee(self): + return True diff --git a/dealership/vehicles.py b/dealership/vehicles.py index 1d0c207..59a607a 100644 --- a/dealership/vehicles.py +++ b/dealership/vehicles.py @@ -1,15 +1,27 @@ class Vehicle(object): def __init__(self, maker, model, year, base_price, miles): - pass + self.maker = maker + self.model = model + self.year = year + self.base_price = base_price + self.miles = miles + + def sale_price(self): + return (self.base_price * self.SALE_PRICE_MULTIPLIER) + + def purchase_price(self): + return (self.sale_price() - (self.PURCHASE_PRICE_MULTIPLIER * self.miles)) class Car(Vehicle): - pass - + SALE_PRICE_MULTIPLIER = 1.2 + PURCHASE_PRICE_MULTIPLIER = 0.004 class Motorcycle(Vehicle): - pass + SALE_PRICE_MULTIPLIER = 1.1 + PURCHASE_PRICE_MULTIPLIER = 0.009 class Truck(Vehicle): - pass + SALE_PRICE_MULTIPLIER = 1.6 + PURCHASE_PRICE_MULTIPLIER = 0.02 From 15c7ebc308c9be1d5ee680b17ba108b797181655 Mon Sep 17 00:00:00 2001 From: "sneha.shinde19" Date: Sat, 21 Jul 2018 22:30:05 -0400 Subject: [PATCH 2/3] updating the read.md file --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 294ed49..10fea8f 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,9 @@ A `LeaseContract` is created by passing the following attributes: The `total_value()` of a `LeaseContract` will be computed in this way: `vehicle.sale_price() + (lease_multiplier) - (discount if employee) * `. In this case `lease_multiplier` depends on the vehicle and is computed in the following way: -* `Car`: `sale_price() + (sale_price() * 1.2 / length_in_months)`. -* `Motorcycle`: `sale_price() + (sale_price() * 1 / length_in_months)` -* `Truck`: `sale_price() + (sale_price() * 1.7 / length_in_months)` +* `Car`: `sale_price() * 1.2 / length_in_months`. +* `Motorcycle`: `sale_price() * 1 / length_in_months` +* `Truck`: `sale_price() * 1.7 / length_in_months` The `monthly_value` of the contract will be just the total value divided by the amount of months: `total_value() / length_in_months`. @@ -104,4 +104,4 @@ Given a Car with `sale_price()` $15,000, a regular customer (not employee) and 1 Given a Truck with `sale_price()` $35,000, a regular customer (not employee) and 36 `length_in_months`: * `total_value()`: `sale_price() + (sale_price() * 1.7 / length_in_months)` = `$35,000 + (35,000 * 1.7 / 36)` = `$36,652.77` -* `monthly_value()`: `total_value() / monthly_payments` = `$36,652.78 / 36` = `$1,018.13` +* `monthly_value()`: `total_value() / monthly_payments` = `$36,652.78 / 36` = `$1,018.13` \ No newline at end of file From 75a0705bcae22ae1ef940a884d3505acb920d55a Mon Sep 17 00:00:00 2001 From: "sneha.shinde19" Date: Sat, 21 Jul 2018 23:44:19 -0400 Subject: [PATCH 3/3] Contracts completed --- dealership/contracts.py | 36 +++++++++++++++++++++++++++++++----- dealership/customers.py | 3 +-- dealership/vehicles.py | 12 +++++++++--- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/dealership/contracts.py b/dealership/contracts.py index c90fe63..de57e9b 100644 --- a/dealership/contracts.py +++ b/dealership/contracts.py @@ -1,12 +1,38 @@ -class Contract(object): - pass +from dealership.customers import Customer, Employee +from dealership.vehicles import Car, Motorcycle, Truck +class Contract(object): + def __init__(self , vehicle, customer): + self.vehicle = vehicle + self.customer = customer class BuyContract(Contract): def __init__(self, vehicle, customer, monthly_payments): - pass - + super(BuyContract, self).__init__(vehicle, customer) + self.monthly_payments = monthly_payments + + def total_value(self): + discount = 0 + if(self.customer.is_employee()): + discount = self.customer.DISCOUNT + total = self.vehicle.sale_price() + (self.vehicle.INTREST_RATE * self.monthly_payments * self.vehicle.sale_price()/100) + return total - (total * discount) + + def monthly_value(self): + return self.total_value() / self.monthly_payments class LeaseContract(Contract): def __init__(self, vehicle, customer, length_in_months): - pass + super(LeaseContract, self).__init__(vehicle, customer) + self.length_in_months = length_in_months + + def total_value(self): + discount = 0 + if(self.customer.is_employee()): + discount = self.customer.DISCOUNT + total = self.vehicle.sale_price() + (self.vehicle.sale_price() * self.vehicle.LEASE_MUTIPLIER / self.length_in_months) + + return total - ( total * discount) + + def monthly_value(self): + return self.total_value() / self.length_in_months diff --git a/dealership/customers.py b/dealership/customers.py index 54c7e66..e4537f8 100644 --- a/dealership/customers.py +++ b/dealership/customers.py @@ -6,14 +6,13 @@ def __init__(self, first_name, last_name, email): class Customer(Person): - pass def is_employee(self): return False class Employee(Person): - DISCOUNT = 10 + DISCOUNT = 0.10 def is_employee(self): return True diff --git a/dealership/vehicles.py b/dealership/vehicles.py index 59a607a..091b73b 100644 --- a/dealership/vehicles.py +++ b/dealership/vehicles.py @@ -11,17 +11,23 @@ def sale_price(self): def purchase_price(self): return (self.sale_price() - (self.PURCHASE_PRICE_MULTIPLIER * self.miles)) - - + class Car(Vehicle): SALE_PRICE_MULTIPLIER = 1.2 PURCHASE_PRICE_MULTIPLIER = 0.004 + INTREST_RATE = 1.07 + LEASE_MUTIPLIER = 1.2 class Motorcycle(Vehicle): SALE_PRICE_MULTIPLIER = 1.1 PURCHASE_PRICE_MULTIPLIER = 0.009 - + INTREST_RATE = 1.03 + LEASE_MUTIPLIER = 1 class Truck(Vehicle): SALE_PRICE_MULTIPLIER = 1.6 PURCHASE_PRICE_MULTIPLIER = 0.02 + INTREST_RATE = 1.11 + LEASE_MUTIPLIER = 1.7 + +