reset password
Author Message
mferras2
Posts: 7
Posted 00:19 Oct 18, 2018 |

I'm currently creating the additional add, find and remove methods for my DB class. InputMismatchException is an exception thrown by the scanner object. When creating these methods do they throw said exception? Slightly confused on where this exception is thrown (the DB methods, menu class or main menu)?

rgallegos
Posts: 29
Posted 00:33 Oct 18, 2018 |

You're on the right path. Scanner throws the exception so when you expect some input and think you'll receive bad data then you would want to catch it. When you create your class that handles the PhoneNumberException then the method that declares it would throw the error. If you want to catch multiple exceptions you can use the bitwise operator OR:  a | b . (Input... | Phone... | Array ex). For the HW,  I created the class and created a constructer that creates the string so I can display what the user typed so I could compare it to what I expect.