def get_cars(self): self.car_dict = {} with open("./data/Cars.csv", "r") as Cars_file: csv_reader = csv.reader(Cars_file) next(csv_reader) for line in csv_reader: plate_num, brand, size, location = line new_car = Car(plate_num, brand, size, location) key = new_car.get_plate_number() # key er platenumber self.car_dict[key] = new_car return self.car_dict
def add_car(self): brand = input("Car Brand: ") model = input("Car Model: ") category = input("Car Category: ") taxti = input("Car rate: ") new_car = Car(brand, model, category, taxti) self.__car_service.add_car(new_car)
def add_new_car(self): ''' búa til user interface þar sem notandinn getur skráð inn nýjan bíl ''' ''' ef bílnúmer er skráð inn vitlaust þarf að láta notandann vita ''' model = input("\n\ttegund bíls: ").strip().capitalize() year = input("\tÁrgerð(YYYY): ").strip() plate = input("\tBílnúmer: ").strip().upper() miles = input("\tKeyrsla bíls (í km): ").strip() color = input("\tLitur bíls: ").strip().capitalize() fuel_type = input("\tEldsneytis tegund(Bensín eða Dísel): ").strip() print("\n\t1. Smábíll\n\t2. Fólksbíll\n\t3. Jeppi\n\t4. Húsbíll") category = input("\tflokkur: ").strip() status = True new_car = Car(model, year, plate, miles, color, fuel_type, category, status) decision = self.__cars.add_car(new_car) if decision == 2: print("\n\tBíl hefur verið bætt á skrá") self.print_car_menu() elif decision == 1: print("\n\tVitlaust skráð inn bílnúmer") self.print_car_menu() #def print_doc(self, filename): """fall sem prentar út í prentara textaskrá sem sett er inn""" """ATH virkar en vantar module win32 í tölvuna svo við commentuðum þetta út"""
def addDetections(self, detections): self.objects = [] for obj in detections: if obj['type'] == "car": self.objects.append(Car(obj)) elif obj['type'] == "person": self.objects.append(Person(obj))
def car_info(self): print("New Car") car_id = input("\tCar ID: ") make = input("\tMake: ") model = input("\tModel: ") manuf_year = input("\tManufacturing Year: ") car_class = input("\tCar Class: ") seats = input("\tSeats: ") doors = input("\tDoors: ") color = input("\tColor: ") transmission = input("\tTransmission: ") fuel_type = input("\tFuel Type: ") price = input("\tPrice: ") tank_size = input("\tTank Size: ") availability = "Yes" if "" in [ car_id, make, model, manuf_year, car_class, seats, doors, color, transmission, fuel_type, price, tank_size ]: _ = input( "Every criteria must be filled in.\nPress Enter to continue..." ) clear() else: new_car = Car(car_id, make, model, manuf_year, car_class, seats, doors, color, transmission, fuel_type, price, tank_size, availability) self.__car_repo.add_car(new_car)
def add_car_ui(self): plate = input("Input plate number: ") if len(plate) != 6: print("Plate number is incorrect!") plate = input("Input plate number: ") make = input("Input make of car: ") new_car = Car(plate, make) CarRepository.add_car(self, new_car)
def get_cars(self): if self.__cars == []: with open("./Data/availablecars.csv", "r", encoding="utf-8", newline="") as cars_file: for line in cars_file.readlines(): plate, make = line.split(",") new_car = Car(plate, make) self.__cars.append(new_car) return self.__cars
def get_car_list(self): car_list = [] car_class_list = [] with open("./data/cars.csv") as cars: csv_reader = csv.reader(cars) for car in csv_reader: car_list.append(car) for car in car_list: new_car = Car(car[0], car[1], car[2], car[3], car[4], car[5], car[6], car[7], car[8], car[9], car[10], car[11], car[12], car[13], car[14], car[15], car[16], car[17]) car_class_list.append(new_car) return car_class_list
def get_car(self): if self.__cars == []: with open("./data/cars.csv", "r") as car_file: for line in car_file.readlines(): (license_plate, make, model, manuf_year, car_class, seats, doors, color, weight, engine_size, horse_power, transmission, fuel_type, price, drive, total_km, tank_size, availability) = line.split(",") new_car = Car(license_plate, make, model, manuf_year, car_class, seats, doors, color, weight, engine_size, horse_power, transmission, fuel_type, price, drive, total_km, tank_size, availability) self.__cars.append(new_car) return self.__cars
def get_cars(self): if self.__cars == []: with open("./Data/cars.csv", "r", encoding="utf-8") as car_file: car_reader = csv.reader(car_file) for line in car_reader: license_plate = line[0] make = line[1] model = line[2] manuf_year = line[3] car_class = line[4] seats = line[5] doors = line[6] color = line[7] weight = line[8] engine_size = line[9] horse_power = line[10] transmission = line[11] fuel_type = line[12] price = line[13] drive = line[14] total_km = line[15] tank_size = line[16] availability = "True" new_car = Car(license_plate, make, model, manuf_year, car_class, seats, doors, color, weight, engine_size, horse_power, transmission, fuel_type, price, drive, total_km, tank_size, eval(availability)) self.__cars.append(new_car) return self.__cars def get_car_list(self): car_list = [] car_class_list = [] with open("./data/cars.csv") as cars: csv_reader = csv.reader(cars) for car in csv_reader: car_list.append(car) for car in car_list: new_car = Car(car[0], car[1], car[2], car[3], car[4], car[5], car[6], car[7], car[8], car[9], car[10], car[11], car[12], car[13], car[14], car[15], car[16], car[17]) car_class_list.append(new_car) return car_class_list
def get_cars(self): if self.__cars == []: with open("./Data/cars.csv", "r", encoding="utf-8") as car_file: car_reader = csv.reader(car_file) for line in car_reader: car_id = line[0] make = line[1] model = line[2] manuf_year = line[3] car_class = line[4] seats = line[5] doors = line[6] color = line[7] transmission = line[8] fuel_type = line[9] price = line[10] tank_size = line[11] availability = line[12] new_car = Car(car_id, make, model, manuf_year, car_class, seats, doors, color, transmission, fuel_type, price, tank_size, availability) self.__cars.append(new_car) return self.__cars
def add_car_repo(self, plate_num, brand, size, location): """Adds car to car repo""" self.new_car = Car(plate_num, brand, size, location) self.cars_info.add_car(plate_num, brand, size, location)
class Salesman_service: def __init__(self): #Repos self.cars_info = Cars_repo() self.salesman_info = Salesman_repo() self.customer_info = Customer_repo() self.log_repo = Log_repo() self.get_orders_dict = Orders_repo() def get_all_cars(self): self.cars_dict = self.cars_info.get_cars() return self.cars_dict.values() def get_available_cars(self): self.available_car_list = [] car_dict = self.cars_info.get_cars() today = datetime.date.today() for value in car_dict.values(): old_orders = value.get_orders() if old_orders != []: for order in old_orders: old_pick_up, old_drop_off = order if (old_pick_up <= today <= old_drop_off): valid = False else: valid = True if valid == True: self.available_car_list.append(value) else: self.available_car_list.append(value) return self.available_car_list def get_unavailable_cars(self): self.unavailable_car_list = [] car_dict = self.cars_info.get_cars() today = datetime.date.today() for value in car_dict.values(): old_orders = value.get_orders() if old_orders != []: for order in old_orders: old_pick_up, old_drop_off = order if (old_pick_up <= today <= old_drop_off): valid = True else: valid = False if valid == True: self.unavailable_car_list.append(value) return self.unavailable_car_list def add_car_repo(self, plate_num, brand, size, location): """Adds car to car repo""" self.new_car = Car(plate_num, brand, size, location) self.cars_info.add_car(plate_num, brand, size, location) def get_customer(self, email): #nær í customer keys úr dict self.customer_dict = self.customer_info.get_customers() #ef keyið passar input frá notanda, returna value úr þeim key for key, value in self.customer_dict.items(): if key == email: self.customer = value return self.customer def order_string(self): """Returns a string of customer orders""" order_string = "" orders = self.customer.get_orders() for order in orders: order_string += "\n" + str(order) + "\n" return order_string def salesman_ID_pw(self, ID, pw): """Takes in pw and id from input and checks if it matches the salesman repository""" valid = False salesman_dict = self.salesman_info.get_salesmen() for key, value in salesman_dict.items(): if key == ID and pw == value.get_password(): self.salesman_id = key self.logged_salesman = value valid = True return valid return valid def change_pw(self, new_pw): """Id is the key in the salesman dictionary, we use the logged in salesman id to find him in the dictionary and update his password by using the change_pw function in the salesman model""" salesman_dict = self.salesman_info.get_salesmen() for key, value in salesman_dict.items(): if key == self.salesman_id: salesman_object = value value.change_pw(new_pw) break self.salesman_info.update_data(salesman_dict) update_repo = self.log_repo update_repo.Update_repo("{} changed his password. ID: {}".format( salesman_object.get_name(), salesman_object.get_ID())) def get_order_info(self, booking_num): order_list = [] order_dict = self.get_orders_dict.get_orders() for values in order_dict.values(): for order in values: if booking_num == order.get_order_num(): order_list.append(order) return order_list def get_log(self): return self.log_repo.Read_repo() def delete_customer(self, customer): """Deletes customer if the email input matches the customer database. Then we update the customer repository.""" cust_dict = self.customer_info.get_customers() cust_dict.pop(customer.get_email()) self.customer_info.add_customers(cust_dict) order_dict = self.get_orders_dict.get_orders() for plate_num, orders in order_dict.items(): for order in orders: if customer.get_email() == order.get_cust_email(): orders.remove(order) self.get_orders_dict.update_order_file(order_dict) def add_to_log(self, ID, brand, plate_num): """Updates log when salesman adds a car to the system""" update_repo = self.log_repo update_repo.Update_repo( "{}, ID: {}, Added {} with plate number {} in {}".format( self.logged_salesman.get_name(), ID, brand, plate_num, self.new_car.get_location_string())) def delete_customer_to_log(self, ID): """Updates log when salesman deletes order""" update_repo = self.log_repo update_repo.Update_repo("{}, ID: {}, deleted customer {} {}".format( self.logged_salesman.get_name(), ID, self.customer.get_first_name(), self.customer.get_last_name()))
def get(self): return Car()
def get_one(weight: int, color: Colors, motor_pwr: int, accel: int, st_wheel_pos: SteeringWheelPositions): car = Car(weight, color) car.motor_power = motor_pwr car.acceleration = accel car.st_wheel_pos = st_wheel_pos return car