-
Notifications
You must be signed in to change notification settings - Fork 0
/
fare_calculator.py
executable file
·31 lines (29 loc) · 1.11 KB
/
fare_calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
import time
class FareCalculator:
def __init__(self, img_path,database,license_plate):
self.img = img_path
self.df = database
self.licplate=license_plate
def insert_df(self,vehicle_type):
self.df.loc[len(self.df)]=[self.licplate,vehicle_type,time.time()]
return self.df
def check_existence(self):
return (self.df['License_Plate_Number']==self.licplate).any()
def calculate_fare(self):
exit_time=time.time()
entry_time=self.df.loc[self.df['License_Plate_Number']==self.licplate,'Entry Time'].iloc[0]
duration=(exit_time-entry_time)/60
vehicle_type=self.df.loc[self.df['License_Plate_Number']==self.licplate,'Vehicle Type'].iloc[0]
if vehicle_type=='Car':
fare=20
if (duration-60)>0:
fare+=(duration-60)*0.4
else:
fare=10
if(duration-60)>0:
fare+=(duration-60)*0.2
return fare
def remove_entry(self):
self.df=self.df[self.df.License_Plate_Number != self.licplate]
return self.df