Esempio n. 1
0
def get_register_menu():
    print("REGISTER NEW USER")
    print()
    customer_name = input("Name : ")
    customer_address = input("Address : ")
    phone_number = input("Phone number : ")
    customer_obj = Customer(customer_name, customer_address, phone_number)
    database.save_customer(customer_obj)
    customer_login_menu()
 def buy_product(self, product_obj, payment_obj, quantity):
     total_price = product_obj.get_price() * quantity
     if payment_obj.get_price() >= total_price:
         bp = database.get_prods_bought(self)
         bp.append(product_obj.get_id())
         database.save_prods_bought(self, bp)
         shipment_obj = Shipment(self.id, product_obj.get_id(), quantity, payment_obj.get_id())
         database.save_shipment(shipment_obj)
         database.save_customer(self)
         return True
     return False
 def buy_products_in_bulk(self, product_list, payment_obj):
     total_price = 0
     i = 0
     for prod in product_list:
         total_price += prod.get_price()
         i += 1
     if payment_obj.get_price() >= total_price:
         i = 0
         for prod in product_list:
             bp = database.get_prods_bought(self)
             bp.append(prod.get_id())
             database.save_prods_bought(self, bp)
             shipment_obj = Shipment(self.id, prod.get_id(), 99, payment_obj.get_id())
             database.save_shipment(shipment_obj)
             i += 1
         database.save_customer(self)
         return True
     return False
 def __init__(self, name, address, phone_number):
     self.name = name
     self.address = address
     self.phone_number = phone_number
     id_list = database.get_customer_ids()
     if not id_list:
         self.id = 0
         id_list.append(0)
         database.save_customer_ids(id_list)
     else:
         list_len = len(id_list)
         last_id = id_list[list_len - 1]
         next_id = last_id + 1
         self.id = next_id
         id_list.append(next_id)
         database.save_customer_ids(id_list)
     database.save_customer(self)
     database.map_customer_name_to_id(self.name, self.id)
Esempio n. 5
0
 def register(self, name, address, ph_no):
     customer_obj = Customer(name, address, ph_no)
     database.save_customer(customer_obj)