Here's a question from my assignment, I need HELP! i'm after a basic structure of code that I can work from. pls try explain steps in code. THANX

Create an application that utilizes your Order class to implement a simple Order tracking system. To do this your system must be able to deal with a number of orders. Your application should have the following capabilities:
1. Create a new order
2. Update an existing order. (Hint: find the order using the tracking number)
3. List all orders.
Your application should be able to deal gracefully with users entering incorrect values when they create an Order, and with users attempting to incorrectly update an order (eg – attempting to ship an unpaid order, or attempting to cancel a shipped order).
As an extension, implement the following capabilities:
1. List all orders for a particular customer
2. Save/load orders from file

Well, you need to first write a class.
That class should have a method that is something like newOrder(), and also a collection orders.
Then work from there.

Here's what I have so far:

class Person(object):
    def __init__(self, trackNo, name, payStatus, shipStatus):
        self.trackNo = trackNo 
        self.payStaus = payStatus
        self.shipStatus = shipStatus
        self.cancelStauts = cancelStatus
    def gettrackNo(self):
        return self.trackNo
    def getpayStatus(self):
        return self.payStatus
    def getshipStatus(self):
        return self.payStatus
    def getcancelStatus(self):
        return self.cancelStatus

Is this how I should be doing it or should I be doing something different?
thanks

wait... why do you have lots of get___ methods?
they are really kind of pointless if it just returns something.
It makes it seem like the trackNo and shipStatus (etc) attributes are "private" as if this was in C# or something.

The methods should do something, like cancel an order, or mark a package as shipped or something, instead of just returning an attribute that can easily be accessed.

Note that #1 is "Create a new order". Start there. Are you going to use a GUI or the command line to enter the order?

Once you have an order, then you have to store it either in memory or on disk, or both.

Once you have the orders stored, you will have to access them in some way, so you will either have to index them or search through the entire file every time you want to find one order.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.