In this lab, you will implement exception handling in ShopV5.0.
On completion of this lab you should be able to:
Store objects into XML files and retrieve them from XML files (using ShopV4.0 as a starting point).
Apply this XML knowledge to another domain i.e. the DVD library.
Include Exception handling for invalid user input.
In this practical, you will create a new project called ShopV5.0 in Eclipse and refactor the code so that exception handling is fully implemented for the user input.
Create a new project called ShopV5.0 and copy the three java files and the jar component from ShopV4.0 into it.
The solution to the ShopV4.0 exercise is here should you need it.
double unitCost = input.nextDouble();
In the previous step, we wrote code to handle the read of the unit cost (double) and the product code (int).
However, there are other reads of int values in the MenuController class that we need to handle.
This would require us re-writing the same code in multiple places. In order, to keep our code DRY, we will write a helper method to validate the int input.
The solution to the ShopV5.0 exercise is here.