This site requires JavaScript, please enable it in your browser!
Greenfoot back
bluebear11
bluebear11 wrote ...

4 days ago

How do I auto generate an ID using arrays? And how do i create a freight status for each freight order?

bluebear11 bluebear11

4 days ago

#
So i have an assignment that requires me to program and create freight Id and update the status for every new order. Freight ID: This should be a unique number auto generated using the following simple algorithm. • Use the numbers '1939' as the first freight Id. Increment it by 1 for the next freight. Freight status: can be one of the codes: ‘D’,’P’, or ‘W’. “D”: Delivered to the destination “P”: Processing “W”: Waiting at the ware house to be delivered. When a new freight order is created, its initial status should be recorded as ‘W’.
danpost danpost

4 days ago

#
No one is going to do your assignment for you. Please, show some attempted code. Also, explain why you think an array is needed to generate IDs.
danpost danpost

4 days ago

#
bluebear11 wrote...
I just thought it was required to store the number in the array and have it auto incremented. This is what I attempted although I know it is completely wrong << Code Omitted >> I just cant seem to understand how I should auto generate and increment a freight ID as well as create a freight status for every new order. Thanks for any help in advance
Hint: the assignment is asking you to describe an object; that is, create a class that creates freight order objects. It will have an ID and a status (as fields). The value of these fields should be assigned during the creation of each instance of the class. Then, in your main (world), you can use an array for these objects and fill the array as you create those instances.
You need to login to post a reply.