def __init__(self): super().__init__("OrderState") # self.view = get_order_view() customer = Customer(objectids.CUSTOMER, 400, 400) customer2 = Customer(objectids.CUSTOMER, 700, 400) customer3 = Customer(objectids.CUSTOMER, 800, 400) self.add_game_object(PRETAKEORDERLINE, priority=1) self.add_game_object(POSTTAKEORDERLINE, priority=1) PRETAKEORDERLINE.add_customer(customer) PRETAKEORDERLINE.add_customer(customer2) PRETAKEORDERLINE.add_customer(customer3) self.add_game_object(TAKEORDERBUTTON)
def interact_mouse_up(self, state, mouse_x, mouse_y): next_state, obj = super().interact_mouse_down(state, mouse_x, mouse_y) if obj is not None: if isinstance(obj, JudgeOkButton): obj = None PRETAKEORDERLINE.add_customer( Customer(objectids.CUSTOMER, 400, 400)) next_state = ORDERSTATE # Maybe change ? # do stuff return next_state, obj
def main(): i = 0 while i < 2: customer_input = int(input("""1. Create an account 2. Log into account 0. Exit """)) print() if customer_input == 0: print('Bye!') return elif customer_input == 1: customer = Customer() print('Your card number:') print(customer.card_number) print('Your card PIN:') print(customer.card_pin) print() else: input_card_number = int(input("""Enter your card number: """)) input_card_pin = int(input("""Enter your PIN: """)) for k, v in Customer.customer_details.items(): if v[0] == input_card_number and v[1] == input_card_pin: print('You have successfully logged in!') customer_input = int(input("""1. Balance 2. Log out 0. Exit """)) print() if customer_input == 0: print("""Bye!""") return elif customer_input == 1: print('Balance: ', v[2]) return else: print('You have successfully logged out!') return else: print('Wrong card number or PIN!') print()
def delete_customers(id): """ Delete a Customer This endpoint will delete a Customer based the id specified in the path --- tags: - Customers description: Deletes a Customer from the database parameters: - name: id in: path description: ID of customer to delete type: integer required: true responses: 204: description: Customer deleted """ customer = Customer.find(redis, id) if customer: customer.delete(redis) return make_response('', HTTP_204_NO_CONTENT)
def add_customer(self, f, l): self.__customers.append(Customer(f, l)) self.__number_of_customers += 1 return self.__customers[len(self.__customers) - 1]
total = 0.0 for x in self.item_price: total += self.item_price[x] print(str(x) + ': ' + str(self.item_price[x])) TAX_RATE = total * TAX_RATE return ('Tax: {0:.2f}'.format(TAX_RATE)) return ('Total: {0:.2f}'.format(total + TAX_RATE)) def display(self): return (str(self.customer.customer_id) + "\n" + str(self.customer.first_name) + " " + str(self.customer.last_name) + "\n" + str(self.customer.address) + "\n" + self.customer.phone_number) def str(self): """returns a string of the Invoice object. same as repr()""" return self.customer.first_name + ' ' + self.customer.last_name + ', ' + self.customer.phone_number def repr(self): """returns a string of the Invoice object. same as str()""" return self.customer.first_name + ' ' + self.customer.last_name + ', ' + self.customer.phone_number # Driver captain_mal = Customer(1, 'Reynolds', 'Mel', 'No phones', 'Firefly, somewhere in the verse') invoice = Invoice(1, captain_mal) invoice.add_item({'iPad': 799.99}) invoice.add_item({'Surface': 999.99}) invoice.create_invoice()
def main(): customer = Customer("A", "T", 36, "1 Main St", "Columbia", "MD", "21046") exporter = CustomerExporter("sample.xml", CustomerConverterType.XMLConverterType) exporter.export_customer(customer)
def insertcustomer(): customer = Customer() typeSelection = int( input( 'Are you a buyer or a seller? Enter 1 for buyer and 2 for seller >> ' )) if typeSelection == 1: customerType = 'buyer' elif typeSelection == 2: customerType = 'seller' else: print('Invalid Customer Type Selection') customer.setCustomerType(customerType) fname = input('What is your first name? >> ') customer.setcustomer_firstname(fname) lname = input('What is your last name? >> ') customer.setcustomer_lastname(lname) age = int(input('What is your age? >> ')) customer.setcustomer_age(age) phone = input('What is your phone? >> ') customer.setcustomer_phone(phone) print()
def SignUp(): print('*' * 6 + 'Welcome user' + '*' * 6) # Inputs from User print("Choose your account type") print("1. Saving") print("2. Current") accType = selectOption( accountType) #To call for check in accountType dictionary fname = validityCheck(0) lname = validityCheck(1) address = input("Enter your address, Line 1: ") address += " " + input("Line 2: ") city = validityCheck(inp=2) state = validityCheck(inp=3) pincode = validatePin() c = Customer(accType, fname, lname, address, city, state, pincode) c.enterPassword() # Registering user to create a customerid acctNo = c.registerUser() # If account type is saving then a default entry is inserted into transactioncount and transactions table if accType == 'Saving': rdate = date.today() + timedelta(days=30) rdate = rdate.strftime("%d-%m-%Y") stmt = "INSERT INTO transactioncount(accountid,renewaldate) values(:1,to_date(:2,'dd-mm-yyyy'))" cur.execute(stmt, {'1': acctNo, '2': rdate}) stamt = "INSERT INTO transactions(accountid) values(:1)" cur.execute(stamt, {'1': acctNo}) con.commit() # If account type is saving then forcing user to deposit 5000 elif accType == 'Current': print("You need to deposit min. amount of Rs. 5000") amt = enterAmount() stmt = "INSERT INTO transactions(accountid,balance) values(:1,:2)" with open( "C:/Users/TushaR/eclipse-workspace/BankingSystem/src/BankingSystem/transactionid.txt" ) as f: file_str = f.read() file_int = int(file_str) file_int += 1 cur.execute(stmt, {'1': acctNo, '2': amt}) stamt = "INSERT INTO statementdetails(id,accountid,balance,transtype) values(:1,:2,:3,:4)" cur.execute(stamt, { '1': file_int, '2': acctNo, '3': amt, '4': 'Credited' }) con.commit() with open( "C:/Users/TushaR/eclipse-workspace/BankingSystem/src/BankingSystem/transactionid.txt", 'w') as f: f.write(str(file_int)) if acctNo: print( "*" * 6 + "You are successfully registered with our bank, you must login now..!\n" ) else: print("*" * 6 + "Error registering")
def get_distance(source: int, dest: int) -> float: global distances return distances.get_distance(source, dest) @staticmethod def get_node(index: int) -> Customer: global customers return customers[index] populations.Chromosome = Chromosome if len(sys.argv) < 2: print("No argument is set, using R101.txt data file as default") filename = 'RC205' else: filename = sys.argv[1] process_timer_start = datetime.now() cust_data = read_data(filename) customers = [Deport(**cust_data[0])] customers += [Customer(**customer_dict) for customer_dict in cust_data] distances = DistanceTable(customers) ga_pop = populations.Population(chromosome_width=len(customers), **populations.population) best_chrome = ga_pop.evolve() print("final solution is:", best_chrome.routes_with_timings) process_time = datetime.now() - process_timer_start print("Time elapsed:" + str(process_time)) write_output(filename, best_chrome.routes_with_timings)
def get_customers(id): """ Get customer with given ID This endpoint will return customer customer information with given ID --- tags: - Customers produces: - application/json parameters: - name: id in: path description: the id to match for finding a customer type: integer required: true responses: 200: description: Customer information schema: id: Customer properties: id: type: integer description: unique id assigned internally by service active: type: boolean description: the status of customer whether it is currently active (false in this case) address_line1: type: string description: address line 1 of the customer address_line2: type: string description: address line 2 of the customer age: type: integer description: age of the customer email: type: string description: email address of the customer first_name: type: string description: first name of the customer last_name: type: string description: last name of the customer gender: type: string description: gender of the customer phonenumber: type: string description: phone number of the customer 404: description: error, Customer was not found """ customer = Customer.find(redis, id) if customer: message = customer.serialize() rc = HTTP_200_OK else: message = {'error': 'Customer with id: %s was not found' % str(id)} rc = HTTP_404_NOT_FOUND return make_response(jsonify(message), rc)
win.title("О программе") win.minsize(width=450,height=300) win.grab_set() lab1 = Label(win, text = "Created: Pavel Belyakov", font="Arial 12 bold").place(x = 0, y = 0) def make(self, flag): if flag == 1: name = 'seller' elif flag == 2: name = 'customer' else: return info = Info(root,name) info.tableInfo() if __name__ == '__main__': #loggerFactory = LoggerFactory() #logger = loggerFactory.getLoggers("MAIN") root = Tk() #dial = Dialog(root) seller = Seller(root) customer = Customer(root) basic = BasicWindows(seller,customer) basic.basicFrame() root.mainloop()
def data_load(payload): customers = Customer(0, payload['first_name'], payload['last_name'], payload['gender'], payload['age'], payload['email'], payload['address_line1'], payload['address_line2'], payload['phonenumber'], True) customers.save(redis)
def search_by_keyword(keyword): """ Retrieve all customers for the given keyword This endpoint will return customers which match given keyword --- tags: - Customers produces: - application/json parameters: - name: keyword in: path description: the keyword to match for returning customers information type: string required: true responses: 200: description: An array of customers schema: type: array items: schema: id: Customer properties: id: type: integer description: unique id assigned internally by service active: type: boolean description: the status of customer whether it is currently active (true) or not (false) address_line1: type: string description: address line 1 of the customer address_line2: type: string description: address line 2 of the customer age: type: integer description: age of the customer email: type: string description: email address of the customer first_name: type: string description: first name of the customer last_name: type: string description: last name of the customer gender: type: string description: gender of the customer phonenumber: type: string description: phone number of the customer """ results = [] results.extend(Customer.search_in_age(redis, keyword)) results.extend(Customer.search_in_first_name(redis, keyword)) results.extend(Customer.search_in_last_name(redis, keyword)) results.extend(Customer.search_in_email(redis, keyword)) results.extend(Customer.search_in_address_line1(redis, keyword)) results.extend(Customer.search_in_address_line2(redis, keyword)) results.extend(Customer.search_in_phonenumber(redis, keyword)) final_results = [] list_ids = [] for res in results: if res.id not in list_ids: final_results.append(res) list_ids.append(res.id) answer = [Customer.serialize(customer) for customer in final_results] return make_response(jsonify(answer), HTTP_200_OK)
def update_customers(id): """ Update customer information This endpoint will return update customer information --- tags: - Customers produces: - application/json parameters: - name: id in: path description: the id to match for finding a customer type: integer required: true - in: body name: body schema: id: data required: - address_line1 - address_line2 - age - email - first_name - last_name - gender - phonenumber properties: address_line1: type: string description: address line 1 of the customer address_line2: type: string description: address line 2 of the customer age: type: integer description: age of the customer email: type: string description: email address of the customer first_name: type: string description: first name of the customer last_name: type: string description: last name of the customer gender: type: string description: gender of the customer phonenumber: type: string description: phone number of the customer responses: 200: description: Customer information schema: id: Customer properties: id: type: integer description: unique id assigned internally by service active: type: boolean description: updated status of customer whether it is currently active (false in this case) address_line1: type: string description: updated address line 1 of the customer address_line2: type: string description: updated address line 2 of the customer age: type: integer description: updated age of the customer email: type: string description: updated email address of the customer first_name: type: string description: updated first name of the customer last_name: type: string description: updated last name of the customer gender: type: string description: updated gender of the customer phonenumber: type: string description: updated phone number of the customer 404: description: error, Customer was not found 400: description: bad request, data was invalid """ customer = Customer.find(redis, id) if customer: active = customer.active payload = request.get_json() payload['active'] = True # make payload complete if Customer.validate(payload): customer = Customer.from_dict(payload) customer.id = id # so that the id in the URI is utilized customer.active = active # restore the activity status customer.save(redis) message = customer.serialize() rc = HTTP_200_OK else: message = {'error': 'Customer data was not valid'} rc = HTTP_400_BAD_REQUEST else: message = {'error': 'Customer %s was not found' % id} rc = HTTP_404_NOT_FOUND return make_response(jsonify(message), rc)
def create_customers(): """ Creates a Customer This endpoint will create a Customer based the data in the body that is posted --- tags: - Customers consumes: - application/json produces: - application/json parameters: - in: body name: body schema: id: data required: - address_line1 - address_line2 - age - email - first_name - last_name - gender - phonenumber properties: address_line1: type: string description: address line 1 of the customer address_line2: type: string description: address line 2 of the customer age: type: integer description: age of the customer email: type: string description: email address of the customer first_name: type: string description: first name of the customer last_name: type: string description: last name of the customer gender: type: string description: gender of the customer phonenumber: type: string description: phone number of the customer responses: 201: description: Customer information schema: id: Customer properties: id: type: integer description: unique id assigned internally by service active: type: boolean description: the status of customer whether it is currently active (false in this case) address_line1: type: string description: address line 1 of the customer address_line2: type: string description: address line 2 of the customer age: type: integer description: age of the customer email: type: string description: email address of the customer first_name: type: string description: first name of the customer last_name: type: string description: last name of the customer gender: type: string description: gender of the customer phonenumber: type: string description: phone number of the customer 400: description: Bad Request (the posted data was not valid) """ id = 0 payload = request.get_json() if Customer.validate(payload): customer = Customer(id, payload['first_name'], payload['last_name'], payload['gender'], payload['age'], payload['email'], payload['address_line1'], payload['address_line2'], payload['phonenumber'], True) customer.save(redis) id = customer.id cust = Customer.find( redis, id ) # added so that the response body of POST matches that of the GET and we compare the results in the TDD in the same format as the json returned by Redis #message = customer.serialize() message = cust.serialize() rc = HTTP_201_CREATED else: message = {'error': 'Data is not valid'} rc = HTTP_400_BAD_REQUEST response = make_response(jsonify(message), rc) if rc == HTTP_201_CREATED: response.headers['Location'] = url_for('get_customers', id=id) return response
opt = int(input()) if opt == 1: service.list_customers() elif opt == 2: id = int(input("Enter customer id: ")) service.get_customer(id) elif opt == 3: id = int(input("Enter customer id: ")) service.list_orders(id) elif opt == 4: id = int(input("Enter customer id: ")) name = raw_input("Enter customer name: ") age = int(input("Enter customer age: ")) gender = raw_input("Enter customer's gender: ") customer = Customer(id, name, age, gender) service.create_customer(customer) elif opt == 5: id = int(input("Enter customer id: ")) service.list_reviews(id) else: print("Please select one from the given options.") elif inp == 3: service = ReviewService(conn) print("1. See all reviews") print("2. Add review") opt = int(input()) if opt == 1: service.list_reviews()
def list_customers(): """ Retrieve all customers or the customers which match given parameter(s) This endpoint will return customers which match given parameter(s) --- tags: - Customers description: The customers endpoint allows you to query customers produces: - application/json parameters: - name: email in: query description: the email to match for returning customers information type: string required: false - name: last-name in: query description: the last name to match for returning customers information type: string required: false - name: first-name in: query description: the first name to match for returning customers information type: string required: false - name: age in: query description: the age to match for returning customers information type: integer required: false - name: gender in: query description: the gender to match for returning customers information type: string required: false - name: address-line1 in: query description: the address line 1 to match for returning customers information type: string required: false - name: address-line2 in: query description: the address line 2 to match for returning customers information type: string required: false - name: phonenumber in: query description: the phone number to match for returning customers information type: string required: false - name: active in: query description: the status of customer to match for returning customers information type: boolean required: false responses: 200: description: An array of customers schema: type: array items: schema: id: Customer properties: id: type: integer description: unique id assigned internally by service active: type: boolean description: the status of customer whether it is currently active (true) or not (false) address_line1: type: string description: address line 1 of the customer address_line2: type: string description: address line 2 of the customer age: type: integer description: age of the customer email: type: string description: email address of the customer first_name: type: string description: first name of the customer last_name: type: string description: last name of the customer gender: type: string description: gender of the customer phonenumber: type: string description: phone number of the customer """ customers = [] email = request.args.get('email') last_name = request.args.get('last-name') first_name = request.args.get('first-name') age = request.args.get('age') gender = request.args.get('gender') address_line1 = request.args.get('address-line1') address_line2 = request.args.get('address-line2') phonenumber = request.args.get('phonenumber') active = request.args.get('active') if email: customers = Customer.find_by_email(redis, email) elif last_name: customers = Customer.find_by_last_name(redis, last_name) elif first_name: customers = Customer.find_by_first_name(redis, first_name) elif age: customers = Customer.find_by_age(redis, age) elif gender: customers = Customer.find_by_gender(redis, gender) elif address_line1: customers = Customer.find_by_address_line1(redis, address_line1) elif address_line2: customers = Customer.find_by_address_line2(redis, address_line2) elif phonenumber: customers = Customer.find_by_phonenumber(redis, phonenumber) elif active: customers = Customer.find_by_activity(redis, str(active).lower()) else: customers = Customer.all(redis) results = [Customer.serialize(customer) for customer in customers] return make_response(jsonify(results), HTTP_200_OK)