How to code this ?

  • vadimak17
  • Newbie
  • Newbie
  • vadimak17
  • Posts: 8

Post 3+ Months Ago

Hello
i need to make a cash register but i dont know how to do it.
i was thinking about to make it in loop but i dont know how to make its. i need to input a barcode of product each barcode has price an stock level. In the loop i will input a barcode all the time untile i input "Done" and then it will out put me total price and show me how mach left in the stok.

abd i was thinking do make it in dicturiany but i dont know how to make the program take out the price.

Thank for any help ;D
in Python 2.7.3
  • Kurthead+1
  • Graduate
  • Graduate
  • Kurthead+1
  • Posts: 131

Post 3+ Months Ago

Are you trying to do this in PHP/SQL or in JavaScript? Would you have an updated SQL database that would keep track of your stock, and prices?
  • vadimak17
  • Newbie
  • Newbie
  • vadimak17
  • Posts: 8

Post 3+ Months Ago

***********************

Python 2.7.3

************************
  • Kurthead+1
  • Graduate
  • Graduate
  • Kurthead+1
  • Posts: 131

Post 3+ Months Ago

vadimak17 wrote:
***********************

Python 2.7.3

************************

Oh, sorry lol. Saw that at the end of your msg now.
  • vadimak17
  • Newbie
  • Newbie
  • vadimak17
  • Posts: 8

Post 3+ Months Ago

its ok ;P So can you help me little bit ;D
  • Kurthead+1
  • Graduate
  • Graduate
  • Kurthead+1
  • Posts: 131

Post 3+ Months Ago

Unfortunately, I have never coded in Python haha. There will be somebody on here that will know and answer your question soon though. They always do. Just make sure to give them as many specifics as you can think of.
  • vadimak17
  • Newbie
  • Newbie
  • vadimak17
  • Posts: 8

Post 3+ Months Ago

i was tryng to do this:
Code: [ Select ]
counter=1
tfoo=0
while counter<2:
  vvv = dict(foo=12, bar=18, baz=244)
  aaa = dict(foo=12, bar=18, baz=244)
  done=counter+4
  tfoo=tfoo+foo

print tfoo
  1. counter=1
  2. tfoo=0
  3. while counter<2:
  4.   vvv = dict(foo=12, bar=18, baz=244)
  5.   aaa = dict(foo=12, bar=18, baz=244)
  6.   done=counter+4
  7.   tfoo=tfoo+foo
  8. print tfoo

but i got erro
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

I cannot help you as far as in the coding. But do you have any of the coding done so far. If so is it giving any errors and what is the error. That will help us out.

Most likely you wont get a good response till the beginning of the week.
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

Why not just get a POS system. Some of them are absolutely amazing, i got a nice touch screen on my 2nd side job that controls most things so mostly tapping a screen and taking cash. If your doing this for a business then you won't want something half arsed as if it fails to work and customers are waiting it never looks good. I see how pissed off customers get when the Card machines decides not to work anymore and it takes several minutes of *peach* around.

If your not sure what your doing then just invest the money into something that works and get on with business, it is an expanse that pays for itself.
  • vadimak17
  • Newbie
  • Newbie
  • vadimak17
  • Posts: 8

Post 3+ Months Ago

Zealous wrote:
Why not just get a POS system. Some of them are absolutely amazing, i got a nice touch screen on my 2nd side job that controls most things so mostly tapping a screen and taking cash. If your doing this for a business then you won't want something half arsed as if it fails to work and customers are waiting it never looks good. I see how pissed off customers get when the Card machines decides not to work anymore and it takes several minutes of *peach* around.

If your not sure what your doing then just invest the money into something that works and get on with business, it is an expanse that pays for itself.


its school sumetive :lol:
  • vadimak17
  • Newbie
  • Newbie
  • vadimak17
  • Posts: 8

Post 3+ Months Ago

This is what i wanted to do in loop.But its not working and i dont know how fix that
Code: [ Select ]
bc=input("Please scan or type a barcode");
caounter=2
tp=0

if caounter<3:

  if bc==04353736:

     price="218$"
     name="i5-3570k"


  if bc==04322575:

    price="493$"
    name="i7-3570k"



  if bc==04201221:

    price="40$"
    name="CM Hyper 212 Evo"



  if bc==03745501:

    price="330$"
    name="AMD HD 7950"



  if bc==01323661:

    price="990$"
    name="GTX Titan"



  if bc==04221214:

    price="49$"
    name="Haf 912 Advance"



  if bc==04664125:

    price="67$"
    name="8GB (2x4GB) 1600"



  if bc==04664125:

    price="67$"
    name="8GB (2x4GB) 1600"



  if bc==07743210:

    price="139$"
    name="MSI Z77A-G43"



  if bc==01236252:

    price="99$"
    name="ADATA 120GB 6GB/S"




  if bc==04625152:

    price="48$"
    name="Razer Deathader"

  if bc==0:
    caounter==4

tp==tp+price
print"",tp

8$"
    name="Razer Deathader"

tp==tp+price
print"",tp
caounter==4
  1. bc=input("Please scan or type a barcode");
  2. caounter=2
  3. tp=0
  4. if caounter<3:
  5.   if bc==04353736:
  6.      price="218$"
  7.      name="i5-3570k"
  8.   if bc==04322575:
  9.     price="493$"
  10.     name="i7-3570k"
  11.   if bc==04201221:
  12.     price="40$"
  13.     name="CM Hyper 212 Evo"
  14.   if bc==03745501:
  15.     price="330$"
  16.     name="AMD HD 7950"
  17.   if bc==01323661:
  18.     price="990$"
  19.     name="GTX Titan"
  20.   if bc==04221214:
  21.     price="49$"
  22.     name="Haf 912 Advance"
  23.   if bc==04664125:
  24.     price="67$"
  25.     name="8GB (2x4GB) 1600"
  26.   if bc==04664125:
  27.     price="67$"
  28.     name="8GB (2x4GB) 1600"
  29.   if bc==07743210:
  30.     price="139$"
  31.     name="MSI Z77A-G43"
  32.   if bc==01236252:
  33.     price="99$"
  34.     name="ADATA 120GB 6GB/S"
  35.   if bc==04625152:
  36.     price="48$"
  37.     name="Razer Deathader"
  38.   if bc==0:
  39.     caounter==4
  40. tp==tp+price
  41. print"",tp
  42. 8$"
  43.     name="Razer Deathader"
  44. tp==tp+price
  45. print"",tp
  46. caounter==4


i wanted to make it works like this progam that i fount in internet
Code: [ Select ]
sum = 0
ans = ''
while ans.lower() != 'done':
  if ans.isdigit():
    sum += int(ans)
  ans = raw_input('Please enter a number ')
print 'Done___________%d' % sum
  1. sum = 0
  2. ans = ''
  3. while ans.lower() != 'done':
  4.   if ans.isdigit():
  5.     sum += int(ans)
  6.   ans = raw_input('Please enter a number ')
  7. print 'Done___________%d' % sum


but i want to input a barcodes and then i will calculate the total price
  • Kurthead+1
  • Graduate
  • Graduate
  • Kurthead+1
  • Posts: 131

Post 3+ Months Ago

Are you not able to use arrays in python?
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Ok so Just to let you know I by no means am a python person, however I downloaded and installed Python 3.3.1 and came up with this that uses an array to hold your product info and a for and if statement to check it.

I'm not sure if this is useful to you or not or if this is what you are after but here is the code

PYTHON Code: [ Select ]
input = "bar2"
arr = [["bar1", "Name of Product 1", "$1,000,000"], ["bar2", "Name of Product 2", "$1,000"], ["bar3", "Name of Product 3", "$100"]]
 
for i in range(len(arr)):
    if input == arr[i][0]:
        print "The " + arr[i][1] + " cost " + arr[i][2]
 
  1. input = "bar2"
  2. arr = [["bar1", "Name of Product 1", "$1,000,000"], ["bar2", "Name of Product 2", "$1,000"], ["bar3", "Name of Product 3", "$100"]]
  3.  
  4. for i in range(len(arr)):
  5.     if input == arr[i][0]:
  6.         print "The " + arr[i][1] + " cost " + arr[i][2]
  7.  


Bar 1 through 3 or index 0 of the array inside of the array would be the barcode for the product this would be a start to your cash register
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

With a little bit more I came up with. I'm not really sure how you would use Python because this is the first time I'm touched it lol. So this is based of concepts of that of PHP where it runs on the the server side. the checkout variable is your shopping cart index 0 is the bar code and the index 1 is the quantity.

It loops through the "shopping cart" then through the products it then matches up the bar codes checks the quantity and remove the items from the in stock number in the arr variable if the are the same amount or more of products in the checkout vs the in stock the stock turns to "Out of stock". it will add up the total regardless.

At the end it spits out the total and the product array

PYTHON Code: [ Select ]
checkout = [["bar1", 4], ["bar2", 8], ["bar3", 19]]
 
arr = [["bar1", "Name of Product 1", 1000000, 4], ["bar2", "Name of Product 2", 1000, 10], ["bar3", "Name of Product 3", 100, 50]]
 
total = 0;
 
for i in range(len(checkout)):
    for j in range(len(arr)):
      if checkout[i][0] == arr[j][0]:
         if checkout[i][1] < arr[j][3]:
                  arr[j][3] = arr[j][3] - checkout[i][1]
               else:
                  arr[j][3] = "Out of Stock"
       
      total = total + (arr[j][2] * checkout[i][1])
 
print "The total is " + str(total)
print arr
 
  1. checkout = [["bar1", 4], ["bar2", 8], ["bar3", 19]]
  2.  
  3. arr = [["bar1", "Name of Product 1", 1000000, 4], ["bar2", "Name of Product 2", 1000, 10], ["bar3", "Name of Product 3", 100, 50]]
  4.  
  5. total = 0;
  6.  
  7. for i in range(len(checkout)):
  8.     for j in range(len(arr)):
  9.       if checkout[i][0] == arr[j][0]:
  10.          if checkout[i][1] < arr[j][3]:
  11.                   arr[j][3] = arr[j][3] - checkout[i][1]
  12.                else:
  13.                   arr[j][3] = "Out of Stock"
  14.        
  15.       total = total + (arr[j][2] * checkout[i][1])
  16.  
  17. print "The total is " + str(total)
  18. print arr
  19.  
  • vadimak17
  • Newbie
  • Newbie
  • vadimak17
  • Posts: 8

Post 3+ Months Ago

but i need to input the barcode that i want not in code
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

That is where the checkout variable comes in. Like i stated i don't know python so i don't know how you are getting the bar code to process it. the example you would need to capture the bar codes and quantities in an array "checkout" and then process it to calculate the total and in stock items.

If python runs like java script you could turn this calc. part into a function and continuously calculate the total. if it runs like php you just have to build the check out array.

this is an example to help guide you to solution since I don't know python

you could do the input function to get the bar code and quantity and then add that info it to the checkout variable

If you can provide some input to how you are getting the bar code or the dictionary thing you were talking about
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Ok so i think i'm starting to get this Python thing

after a bit of fooling around today i came up with this. this will constantly ask you to enter a bar code and then a quantity when you want to check out type done and it will total up the entered items and update the inventory array.
PYTHON Code: [ Select ]
checkout = []
 
# the entries go barcode, name of product, price, number in stock
inventory = [["bar1", "Name of Product 1", 1000000, 4],
             ["bar2", "Name of Product 2", 1000, 10],
             ["bar3", "Name of Product 3", 100, 50]
            ]
total = 0;
 
def running():
    global total
    global checkout
    barcode = input("Enter Barcode ")
    if barcode != 'done':
        amount = input("How many ")
        checkout.append([barcode, int(amount)])
        running()
    else:
        calc()
        print("The Total is " + str(total))
        print(inventory)
 
def calc():
    global total
    global checkout
    global inventory
    for i in range(len(checkout)):
        for j in range(len(inventory)):
            if checkout[i][0] == inventory[j][0]:
                if checkout[i][1] < inventory[j][3]:
                    inventory[j][3] = inventory[j][3] - checkout[i][1]
                else:
                    inventory[j][3] = "Out of Stock"
                total = total + (inventory[j][2] * checkout[i][1])
    return total
 
running()
 
  1. checkout = []
  2.  
  3. # the entries go barcode, name of product, price, number in stock
  4. inventory = [["bar1", "Name of Product 1", 1000000, 4],
  5.              ["bar2", "Name of Product 2", 1000, 10],
  6.              ["bar3", "Name of Product 3", 100, 50]
  7.             ]
  8. total = 0;
  9.  
  10. def running():
  11.     global total
  12.     global checkout
  13.     barcode = input("Enter Barcode ")
  14.     if barcode != 'done':
  15.         amount = input("How many ")
  16.         checkout.append([barcode, int(amount)])
  17.         running()
  18.     else:
  19.         calc()
  20.         print("The Total is " + str(total))
  21.         print(inventory)
  22.  
  23. def calc():
  24.     global total
  25.     global checkout
  26.     global inventory
  27.     for i in range(len(checkout)):
  28.         for j in range(len(inventory)):
  29.             if checkout[i][0] == inventory[j][0]:
  30.                 if checkout[i][1] < inventory[j][3]:
  31.                     inventory[j][3] = inventory[j][3] - checkout[i][1]
  32.                 else:
  33.                     inventory[j][3] = "Out of Stock"
  34.                 total = total + (inventory[j][2] * checkout[i][1])
  35.     return total
  36.  
  37. running()
  38.  
  • vadimak17
  • Newbie
  • Newbie
  • vadimak17
  • Posts: 8

Post 3+ Months Ago

Thank you so mach ;D
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Your welcome it was a fun learning experience.
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

So I couldn't help myself I had fun doing this but I ran away with it lol

That script I just posted yesterday is already been completely remade lol and well it got a bit out of hand. Now there is a cancel lol

Usage is you type or scan a barcode if there is more than one item hit the spacebar and type the number of items when your done type done if you want to cancel type cancel

when in done it will ask how much the customer is giving you you type that in and it will tell you the change to give and print out a receipt it will also figure in sales tax lol which now that i think about it i should include that into the sub totaling. typing cancel at at time on any prompt will cancel the order.

PYTHON Code: [ Select ]
# The entries go barcode, name of product, price, number in stock. This is a stand in for a database connection. Good tutorial I found http://www.tutorialspoint.com/python/python_database_access.htm
inventory = [["bar1", "Name of Product 1", 1000000, 4],
             ["bar2", "Name of Product 2", 1000, 10],
             ["bar3", "Name of Product 3", 100, 50]
            ];
 
# Outside varaibles
cart = [];
sub_total = 0;
total = 0;
tax_rate = .095;
tax = 0;
change = 0;
 
# This will be the function that builds up the cart
def register():
 
    # Get the outside varaibles
    global sub_total;
    global cart;
 
    # Get the barcode to add more than one item at a time type in a space followed by the quantity
    barcode = input('Scan or Type Barcode: ');
 
    # Check for the completion of the order
    if barcode.lower() == 'done':
 
        # The order is complete so do the final calculation
        complete_order();
 
    # Check for nothing
    elif barcode.lower() == '':
 
        # Send error and restar the register
        print('You must enter something.');
        register();
 
    # Check for cancel order
    elif barcode.lower() == 'cancel':
 
        # Call the cancel order function
        cancel_order();
   
    # This will handel the most the math and inventory
    else:
       
        # Split the barcode on a space
        parts = barcode.split( );
       
        # Loop inventory to check a few things
        for i in range(len(inventory)):
 
            # Check to see if the barcode exists
            if inventory[i][0] == parts[0].lower():
       
                # Check to see if there is a quantity attached
                if len(parts) > 1:
 
                    # Set the quantity
                    quantity = int(parts[1].lower());
 
                else:
 
                   # Quantity is one
                   quantity = 1;
 
                # Calculate total_price
                total_price = inventory[i][2] * quantity;
 
                # Add to sub total
                sub_total = sub_total + total_price;
 
                # Check the inventory
                if quantity < inventory[i][3]:
 
                    # Update the inventory
                    inventory[i][3] = inventory[i][3] - quantity;
                   
                else:
                   
                    # Update the inventory
                    inventory[i][3] = "Out of Stock";
 
                # Add to the cart as follows name of barcode, product, quantity, price per item, total price
                cart.append([parts[0].lower(), inventory[i][1], quantity, inventory[i][2], total_price]);
           
                # Kickout of loop
                break;    
           
        # Show the sub total
        print('Sub Total: ' + str(sub_total));
       
        # Run the register function again
        register();
 
def complete_order():
 
    # Get the outside varaibles
    global tax_rate;
    global tax;
    global sub_total;
    global total;
    global change;
    global cart;
   
    # Calulate total
    pre_tax = sub_total * tax_rate;
    pre_total = pre_tax + sub_total;
 
    # Ask for the amount given
    amount = input('How much money were you given? ');
 
    # Check for cancel order
    if amount.lower() == 'cancel' or amount.lower() == '':
 
        # Call the cancel order function
        cancel_order();
   
    # This will handel the math
    else:
 
        # Make sure we have more money than the total
        if float(amount) > float(pre_total):
 
            # Set tax and total
            tax = pre_tax;
            total = pre_total;
           
            # Calculate the change
            change = float(amount) - float(total);
 
            # Show how much change to give
            print('Change ' + str(change));
            print(' ');
 
            # Start the recipt
            print(' ');
            print('Receipt');
            print("Item\tQuantity\tPrice\tTotal\t");
 
            # Print the recipt out
            for i in range(len(cart)):
 
                # Print the item out
                print(str(cart[i][1]) + "\t" + str(cart[i][2]) + "\t" + str(cart[i][3]) + "\t" + str(cart[i][4]));
 
            print(' ');
            print('Sub Total' + "\t\t\t\t" + str(sub_total));
            print('Tax' + "\t\t\t\t\t" + str(tax));
            print('Total' + "\t\t\t\t\t" + str(total));
            print('Amount Given' + "\t\t\t\t" + str(amount));
            print('Change' + "\t\t\t\t\t" + str(change));
            print(' ');
            print(' ');
 
            # Restart the program
            reset();
 
        # Restart this function
        else:
 
            # Send error and restart this function
            print('You Need to enter an amount greater than the total.');
            complete_order();
 
def reset():
 
    # Get the outside varaibles
    global tax;
    global sub_total;
    global total;
    global change;
    global cart;
 
    # Reset outside varaibles
    cart = [];
    sub_total = 0;
    total = 0;
    tax = 0;
    change = 0;
 
    # Run the register function
    print(' ');
    print(' ');
    register();
 
def cancel_order():
 
    # Get the outside varaibles
    global cart;
    global inventory;
   
    # Loop the cart
    for i in range(len(cart)):
 
        # Loop the inventory
        for j in range(len(inventory)):
 
            # Find a match
            if cart[i][0] == inventory[j][0]:
 
                # Add the inventory back
                inventory[j][3] = inventory[j][3] + cart[i][2];
   
    # Reset the program
    reset();
 
# Run the register function
register();
 
 
  1. # The entries go barcode, name of product, price, number in stock. This is a stand in for a database connection. Good tutorial I found http://www.tutorialspoint.com/python/python_database_access.htm
  2. inventory = [["bar1", "Name of Product 1", 1000000, 4],
  3.              ["bar2", "Name of Product 2", 1000, 10],
  4.              ["bar3", "Name of Product 3", 100, 50]
  5.             ];
  6.  
  7. # Outside varaibles
  8. cart = [];
  9. sub_total = 0;
  10. total = 0;
  11. tax_rate = .095;
  12. tax = 0;
  13. change = 0;
  14.  
  15. # This will be the function that builds up the cart
  16. def register():
  17.  
  18.     # Get the outside varaibles
  19.     global sub_total;
  20.     global cart;
  21.  
  22.     # Get the barcode to add more than one item at a time type in a space followed by the quantity
  23.     barcode = input('Scan or Type Barcode: ');
  24.  
  25.     # Check for the completion of the order
  26.     if barcode.lower() == 'done':
  27.  
  28.         # The order is complete so do the final calculation
  29.         complete_order();
  30.  
  31.     # Check for nothing
  32.     elif barcode.lower() == '':
  33.  
  34.         # Send error and restar the register
  35.         print('You must enter something.');
  36.         register();
  37.  
  38.     # Check for cancel order
  39.     elif barcode.lower() == 'cancel':
  40.  
  41.         # Call the cancel order function
  42.         cancel_order();
  43.    
  44.     # This will handel the most the math and inventory
  45.     else:
  46.        
  47.         # Split the barcode on a space
  48.         parts = barcode.split( );
  49.        
  50.         # Loop inventory to check a few things
  51.         for i in range(len(inventory)):
  52.  
  53.             # Check to see if the barcode exists
  54.             if inventory[i][0] == parts[0].lower():
  55.        
  56.                 # Check to see if there is a quantity attached
  57.                 if len(parts) > 1:
  58.  
  59.                     # Set the quantity
  60.                     quantity = int(parts[1].lower());
  61.  
  62.                 else:
  63.  
  64.                    # Quantity is one
  65.                    quantity = 1;
  66.  
  67.                 # Calculate total_price
  68.                 total_price = inventory[i][2] * quantity;
  69.  
  70.                 # Add to sub total
  71.                 sub_total = sub_total + total_price;
  72.  
  73.                 # Check the inventory
  74.                 if quantity < inventory[i][3]:
  75.  
  76.                     # Update the inventory
  77.                     inventory[i][3] = inventory[i][3] - quantity;
  78.                    
  79.                 else:
  80.                    
  81.                     # Update the inventory
  82.                     inventory[i][3] = "Out of Stock";
  83.  
  84.                 # Add to the cart as follows name of barcode, product, quantity, price per item, total price
  85.                 cart.append([parts[0].lower(), inventory[i][1], quantity, inventory[i][2], total_price]);
  86.            
  87.                 # Kickout of loop
  88.                 break;    
  89.            
  90.         # Show the sub total
  91.         print('Sub Total: ' + str(sub_total));
  92.        
  93.         # Run the register function again
  94.         register();
  95.  
  96. def complete_order():
  97.  
  98.     # Get the outside varaibles
  99.     global tax_rate;
  100.     global tax;
  101.     global sub_total;
  102.     global total;
  103.     global change;
  104.     global cart;
  105.    
  106.     # Calulate total
  107.     pre_tax = sub_total * tax_rate;
  108.     pre_total = pre_tax + sub_total;
  109.  
  110.     # Ask for the amount given
  111.     amount = input('How much money were you given? ');
  112.  
  113.     # Check for cancel order
  114.     if amount.lower() == 'cancel' or amount.lower() == '':
  115.  
  116.         # Call the cancel order function
  117.         cancel_order();
  118.    
  119.     # This will handel the math
  120.     else:
  121.  
  122.         # Make sure we have more money than the total
  123.         if float(amount) > float(pre_total):
  124.  
  125.             # Set tax and total
  126.             tax = pre_tax;
  127.             total = pre_total;
  128.            
  129.             # Calculate the change
  130.             change = float(amount) - float(total);
  131.  
  132.             # Show how much change to give
  133.             print('Change ' + str(change));
  134.             print(' ');
  135.  
  136.             # Start the recipt
  137.             print(' ');
  138.             print('Receipt');
  139.             print("Item\tQuantity\tPrice\tTotal\t");
  140.  
  141.             # Print the recipt out
  142.             for i in range(len(cart)):
  143.  
  144.                 # Print the item out
  145.                 print(str(cart[i][1]) + "\t" + str(cart[i][2]) + "\t" + str(cart[i][3]) + "\t" + str(cart[i][4]));
  146.  
  147.             print(' ');
  148.             print('Sub Total' + "\t\t\t\t" + str(sub_total));
  149.             print('Tax' + "\t\t\t\t\t" + str(tax));
  150.             print('Total' + "\t\t\t\t\t" + str(total));
  151.             print('Amount Given' + "\t\t\t\t" + str(amount));
  152.             print('Change' + "\t\t\t\t\t" + str(change));
  153.             print(' ');
  154.             print(' ');
  155.  
  156.             # Restart the program
  157.             reset();
  158.  
  159.         # Restart this function
  160.         else:
  161.  
  162.             # Send error and restart this function
  163.             print('You Need to enter an amount greater than the total.');
  164.             complete_order();
  165.  
  166. def reset():
  167.  
  168.     # Get the outside varaibles
  169.     global tax;
  170.     global sub_total;
  171.     global total;
  172.     global change;
  173.     global cart;
  174.  
  175.     # Reset outside varaibles
  176.     cart = [];
  177.     sub_total = 0;
  178.     total = 0;
  179.     tax = 0;
  180.     change = 0;
  181.  
  182.     # Run the register function
  183.     print(' ');
  184.     print(' ');
  185.     register();
  186.  
  187. def cancel_order():
  188.  
  189.     # Get the outside varaibles
  190.     global cart;
  191.     global inventory;
  192.    
  193.     # Loop the cart
  194.     for i in range(len(cart)):
  195.  
  196.         # Loop the inventory
  197.         for j in range(len(inventory)):
  198.  
  199.             # Find a match
  200.             if cart[i][0] == inventory[j][0]:
  201.  
  202.                 # Add the inventory back
  203.                 inventory[j][3] = inventory[j][3] + cart[i][2];
  204.    
  205.     # Reset the program
  206.     reset();
  207.  
  208. # Run the register function
  209. register();
  210.  
  211.  

Post Information

  • Total Posts in this topic: 20 posts
  • Users browsing this forum: No registered users and 147 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.