I've been pulling my hair out over this program. It is uses a Class for creating objects to be used in an ordering tracking system. I'm having problems calling the objects and implementing them.
I'm trying to follow a structure along these lines
When an order is created payment is unconfirmed
orders must be paid before any other processing
unpaid orders can't be shipped
orders cannot be completed unless they are shipped
orders cannot be cancelled after they are shipped
The timestamp parameter is supposed to be called at the end of each method to increment a counter by 1 so that steps in the order cannot be skipped once the counter hits a certain value. But I can't even get a step in the process to work. I hope this makes sense
class Order(object): def __init__(self, tracker, timestamp): '''This is the constructor we give it 2 arguments''' self.tracker = tracker self.time = time print ('New order created').format(self.tracker) self.__timestamp() def pay(self,payment): '''This is a method that belong to Order class''' self.payment = payment self.payment_timer = timer print('Enter payment: ') self.__timestamp() def ship(self,timestamp): self.timestamp = timestamp self.__timestamp() def complete(self, timestamp): self.timestamp = timestamp self.__timestamp() def cancel(self, timestamp): self.timestamp = timestamp self.__timestamp() def __str__(self): '''Return a pleasant representation''' return "tracking_number %s payment %.2f payment_timer %s" % (self.tracker, self.payment,self.payment_timer) def __timestamp(self, time): self.time += 1 time = time.localtime(time.time()) return "%02d.%02d.%02d.%02d.%02d" % (lt, lt, lt, lt, lt) def main(): orderNumber = input("Order tracking number 5 digits: ") newOrder = Order(orderNumber) choice = None while choice != '0': print \ '''Order Tracking System 0 - Quit 1 - New Order 2 - Pay Order 3 - Ship order 4 - Complete Order 5 - Cancel Order 6 - Display Order ''' choice = input('Enter decision: ') if choice == "0": print("Good-bye.") elif choice == 2: Order.pay() elif choice == 3: Order.ship() elif choice == 4: Order.complete() elif choice == 5: Order.cancel() elif choice == 6: Order.__str__() else: print "Invalid selection", choice, "isn't valid." if __name__ == "__main__": main()
I keep getting an argument error on the first part of main, requires atleast 3 arguments and only 2 given...This confuses me because it considers 'self' in the error
Anyone have any ideas?
Edited 6 Years Ago by Ultralisk: n/a