Poor testers for Cash Register Challenge

I’ll omit posting my code, not sure if you that’s allowed.

Here are the tester functions;

checkCashRegister(19.5, 20, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);

checkCashRegister(3.26, 100, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);

checkCashRegister(19.5, 20, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]);

checkCashRegister(19.5, 20, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]);

checkCashRegister(19.5, 20, [["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]);

These are the results for the code I wrote:

{ status: 'OPEN', change: [ [ 'QUARTER', 0.5 ] ] }
{
  status: 'OPEN',
  change: [[ 'PENNY', 0.04 ],[ 'DIME', 0.2 ],[ 'QUARTER', 0.5 ],[ 'ONE', 1 ],[ 'FIVE', 15 ],[ 
 'TEN', 20 ],[ 'TWENTY', 60 ]
  ]
}
{ status: 'INSUFFICIENT_FUNDS', change: [] }
{ status: 'INSUFFICIENT_FUNDS', change: [] }
{ status: 'CLOSED', change: [ [ 'PENNY', 0.5 ] ] }

Here are the expected results:

{status: "OPEN", change: [["QUARTER", 0.5]]}

{status: "OPEN", change: [["TWENTY", 60], ["TEN", 20], ["FIVE", 15], 
["ONE", 1], ["QUARTER", 0.5], ["DIME", 0.2], ["PENNY", 0.04]]}

{status: "INSUFFICIENT_FUNDS", change: []}

{status: "INSUFFICIENT_FUNDS", change: []}

{status: "CLOSED", change: [["PENNY", 0.5], ["NICKEL", 0], 
["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], 
["TWENTY", 0], ["ONE HUNDRED", 0]]}

As you can see, the expected results are inconsistent.

  • They are inconsistent on whether keep or not the keys with 0 value, like in the last case.

  • They are inconsistent on whether they should be sorted from pennys to hundreds or viceversa, like in second case.

Those are different cases, they really shouldn’t be compared directly.

  • With status CLOSED, cash-in-drawer is to be returned.
  • For OPEN status change should include coins and bills sorted from highest to lowest.
1 Like

Geeez!!! The story needs better explanation.