Author | Message |
---|---|
mdomin52
Posts: 3
|
Posted 00:45 Mar 13, 2018 |
When the user is creating a Faculty, Staff, or Student, are we required to use exception handling for all situations such as: 1) User inputs a string when asked for an integer 2) User inputs a negative number for salary. 3) User inputs a string other than Full Time or Part Time in rank and then have the user reinput a valid entry? |
kknaur
Posts: 540
|
Posted 09:49 Mar 13, 2018 |
1) You should use exception handling to validate correct in put types. 2) This is up to you, try it out with exception handling to get some practice with it. 3) This can be taken care of in a few ways, give the user a choice of ONLY the valid options (i.e. enter 1 for this and 2 for that, etc), use a simple if statement to validate what they entered, or yes you could use exception handling.
Really it is up to your discretion. As discussed in class, you don't want to use exception handling for EVERYTHING, but it is useful for allowing a client of your class to decide what to do when a particular error occurs. Just try to get enough practice with it that you understand how it works. Last edited by kknaur at
09:49 Mar 13, 2018.
|