HardwareStoreWithException Program
Description
This program uses the exception handling techniques to handle possible exceptions in the HardwareStore project.Associated Concepts:
Exception Handling
Algorithm:
main method:
Use try and catch mechanism to handle file IO exceptions instead of using
the throw clause in the main() method signature.
Handle the InputMismatchException for the user input of case number.
Handle exception in each case in the event that the array was not populated correctly.
populateArray() method definition:Handle the InputMismatchException for the user input of case number.
Handle exception in each case in the event that the array was not populated correctly.
If the data file has more data items than the array size, the try block terminates
immediately, and the program execution jumps to the matching
catch block to handle the IndexOutOfBoundsException.
If the data file has missing data item, the try block terminates immediately, and the program execution jumps to the matching catch block to handle the NoSuchElementException.
The catch block with the superclass Exception type handles any unexpected exceptions.
If the data file has missing data item, the try block terminates immediately, and the program execution jumps to the matching catch block to handle the NoSuchElementException.
The catch block with the superclass Exception type handles any unexpected exceptions.