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’.
I have tried some ways but i just cant seem to understand how I should auto generate and increment a freight ID as well as create a freight status.
public void freightID()
{
int [] freightID = {1939,1939,1939,1939,1939};
for (int i = 0; i<ID_SIZE; i++)
{
int answer = ++freightID[0];
System.out.println(freightID[i]*1);
}
}
I know this is completely wrong but i just wanted to show what i tried.
So as far as I understand your assignment you have to create a class "Order" which has the attribute "freight ID" and "status". The first order will start with the ID 1939 and every new Order needs to increment this number. Creating such Order the status is W. After the creation of the order you want to have the possibility to change the status. If thats correct i have the solution for you:
I hope thats it what you asked for, if not, please clarify your question.