Bug 207 - Incorrect loop handler when Courier is checking out Orders from Branch office
Summary: Incorrect loop handler when Courier is checking out Orders from Branch office
Status: RESOLVED FIXED
Alias: None
Product: Group 1
Classification: Unclassified
Component: Branch (show other bugs)
Version: v0.1-alpha
Hardware: Macintosh Mac OS
: --- normal
Assignee: WANG Ruochen
URL:
Depends on: 454
Blocks:
  Show dependency tree
 
Reported: 2017-11-25 20:42 HKT by lpzjerry
Modified: 2020-11-24 22:21 HKT (History)
2 users (show)

See Also:


Attachments
Branch source code (3.54 KB, text/plain)
2017-11-25 20:42 HKT, lpzjerry
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lpzjerry 2017-11-25 20:42:41 HKT
Created attachment 1 [details]
Branch source code

Bug reproduce:
1. Instantiate a Branch office
2. Add Orders (as test stub) to the Order Queue
3. Assign the Orders to the Courier

Expected Output:
The orders are assigned if the Queue is empty

Program Rundown:
The list is empty while the loop did not exit

In Branch.java, line 97:
    while (weight < courier.getCapacity() && thingsToSend.size() > 0) {
                                             ^
thingsToSend refers the ArrayList which will be assigned to the Courier, rather than the list of the undelivered Order Queue.