com.andrew.Parser
Assumptions: 1. The supplied expected output shouldn't (can't) be 100% emulated since its currency formatting is inconsistent. (Sometimes the format is Rands and Cents, other times just Rands) Below is the output from the unit test written to drive my development -------------------------------------------------------------- line 3: actualLine not equal to expectedLine line 3: actualLine:'3,Bag of ice,5,R10.00,R1.40,R57.00' line 3: expectedLine:'3,Bag of ice,5,R10,R1.40,R57' line 4: actualLine not equal to expectedLine line 4: actualLine:'4,2l Coke,2,R20.00,R2.80,R45.60' line 4: expectedLine:'4,2l Coke,2,R20,R2.80,R45.60' -------------------------------------------------------------- However, on line 2, the expected unit price is R5.00, not R5, so there seems to me to be no consistent rule for this that I can implement. 2. Although use of an external CSV-parsing library is a better idea for a production system, I've deemed this just a distraction for the purposes of this exercise. 3. For error handling, I've just coded up some simple messages to stdout. Without more information about the production environment in which this would run it doesn't feel like I can do much more.
@author andrew