On 03/08/16 06:34, Justin Korn via Tutor wrote: > Data for Analysis is saved in this order on each line of the file: > [orderNumber, partNumber, quantyNumber, aisleNumber, shelfNumber, binNumber] > > > This is what I have so far: > > infile = open("warehouse_data.txt", "r") > > class Order(): > def __init__(self, order_number, line_items): > self.order_number = order_number > line_items = line_items
You use self for the order_number but not for the line_items? Also, are you really planning on building a collection of line items per order before you create the order? Or might it be better to create the order for the first identified line item and then add() subsequent line items as you find them? Just a thought... > class LineItem(): > def __init__(self, orderNumber, partNumber, quantityNumber, aisleNumber, > shelfNumber, binNumber): > self.orderNumber = orderNumber > self.partNumber = partNumber > self.quantityNumber = quantityNumber > self.aisleNumber = aisleNumber > self.shelfNumber = shelfNumber > binNumber = binNumber And similarly you do not use self for bin_number In each case the values without self will be thrown away when the __init__() method exits. Other than that issue it's a fair start in that you now have two classes that can be used to store the data in the file. Your next step is presumably to read the file into objects of these classes. Finally, I'm guessing you'll want to sort the line items into groups based on their location so that the warehouse pickers don't need to visit the same area twice. I'm not clear whether that should be limited per order or to all the line items per batch and the collected items assembled into orders later. I'm assuming that the items are picked by order... but the assignment doesn't seem to specify. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor