trz-maier / hwu-ase-group2

2 stars 2 forks source link

Adding random orders while orders from file are still being added stops further orders from file being added to the queue #155

Closed trz-maier closed 5 years ago

trz-maier commented 5 years ago

If you try adding random orders right after program starts you can see that no further orders from the file are being added

trz-maier commented 5 years ago

This is now kind of fixed but random orders get added and pushed to the end of the queue - is this expected behaviour or another bug?

jathanasiou commented 5 years ago

Because of the sorting implemented for Order objects, they are placed in the queue depending on two criterias

  1. Priority
  2. Then, creation time/order of the instance. Older instances go first.

https://github.com/trz-maier/hwu-ase-group3/blob/0e2b52259458bb6f2cdef978ce140ce31812a2e9/src/ase/cw/model/Order.java#L120-L132

In sort, this works as expected and it was a choice taken during the implementation, though could be easily changed if desired.

trz-maier commented 5 years ago

I don't think I am understood. I am talking about orders of the same priority not being sorted by the time they are added when both randomly generated orders and orders from file are simultaneously added to the queues. Like I said in my previous comment randomly generated orders seems to be pushed to the end of the queue regardles of whether they are added before or after orders from the file

Orangefruit2 commented 5 years ago

we can use the Date timestamp to sort. Instead of adding the timestamp, as soon as the order is taken by the server, we can add a timestamp -as previously - when we create the order

trz-maier commented 5 years ago

Can we not set a date or counter of Order being added to the queue as opposed to object being created? This sounds like a simple solution. Just create a setCounter method for the Order and have the OrderQueue call it when adding

Orangefruit2 commented 5 years ago

a function like setCounter would work, but would be a bit hacky, since you can not guarantee that you always set the counter. Using the timestamp again when the object is created(as in CW1) should be fine, since the date is mandatory. But the cw requirements don't tell us that we have to set the date when the server finishes the order. But i am fine with both Solutions.

trz-maier commented 5 years ago

moved to #160