Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I hate to be the bearer of bad news but for a problem this specific with an algorithm of this complexity, you're unlikely to get a pinpoint answer.</p> <p>What I can suggest to help you find your bug(s):</p> <ul> <li>You have a lot of collections, in particular arrays of differing sizes. It doesn't really surprise me that you're getting some "out of whack" positions given this</li> <li>It looks like you've taken an algorithm expressed in a non-OO language (or perhaps pseudocode) - it could be worth setting up a new class to represent a <code>Taxi</code> and a <code>Passenger</code>, holding all the pertinent details inside, rather than trying to index into a particular array position of a particular array</li> <li>You have a mixture of method parameters and member variables that means your <code>TaxiScheduler</code> can actually only deal with one call to <code>doGaleShapley()</code> at a time. This will probably bite you later on unless you move <em>all</em> those member variables into the method</li> <li>Using "naked" <code>ArrayList</code>s is a double-no-no: <code>List&lt;Taxi&gt;</code> gives you type-safety while not forcing your client to use an <code>ArrayList</code></li> <li>Refactor your <code>doGaleShapley()</code> method into smaller, self-contained, well-named methods that <strong>do one thing only</strong></li> <li><strong>Use Unit Tests</strong> to simulate each possible situation. Each test should be named after a desired functionality (e.g. <code>shouldReturnEmptyWaitingListIfNoPassengersProvided</code>) and consist of <code>Given - When - Then</code> statements that set up a scenario, exercise your function, and verify the results are as expected. If you've refactored your big method into smaller ones, it will be very easy to name your tests and make sure you're covering everything. You can also use a code coverage tool like <a href="http://cobertura.sourceforge.net/" rel="nofollow">Cobertura</a> to ensure all your branches are being hit.</li> <li>If, after doing all this, you still can't figure it out, you should at least have a smaller snippet of code that you can post here :-)</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload