Tuesday, April 12, 2011

Tricky Tricky Bug

So, it turns out that Bug#4 is a bit trickier than we thought.  Bug #4 is a problem with how the Lemonade Stand game requires the user to enter their profit.  The game wants the user to enter the amount using the fewest coins possible and originally reported an incorrect amount if this condition was not met.  Our team thought this was confusing so we wanted to create multiple error messages - one if an incorrect amount was entered and another if the correct amount was entered, but not using the fewest coins possible.  Shannon and Francis were able to find the section of code where this needed to be fixed and even fixed it.  This was no easy task, but with some perseverance it was done and it was done by our self-imposed deadline.  However, that is where things got tricky...

Following the best practices taught here at CofC, Shannon began thoroughly testing his solution and discovered that while the code he wrote was good, the original code confirming that the correct amount was entered with the fewest coins possible was wrong!  It only requires the three largest denominations (dollar, quarter, dime) to be 'correct.'  Beyond that, the user may enter any valid combination of nickels and pennies to complete the amount.

As I've been considering that problem, it occurs to me that maybe this is not an error, but was actually done intentionally.  This more closely models real life as a cashier may run out of certain denominations of dollars and coins.  It makes some sense that the game would require the larger denominations to be correct in order to prevent the user from simply entering the amount in pennies or dimes or quarters.  I hope this afternoon in class to discuss this with the team and if we decide to enforce absolute fewest coins possible, then hopefully we can figure out the necessary change.

No comments:

Post a Comment