PROG24178 Lecture Notes - Lecture 22: Exception Handling, Negative Number, Mutator Method
Document Summary
Today we will be covering exception handling with inheritance, getter methods, and setter methods. * @author palomads public class throwsexample { //create a new project called throwsexample. * @param args the command line arguments public static void main(string[] args) { try { Manager one = new manager(); one. sethours(integer. parseint(args[0]));//set it to the first command line argument and turn that command line argument into an integer. } catch (exception e) {//catch the exception from manager class, i called my exception e. Worker two = new worker();//first object from second class two. sethours(integer. parseint(args[0]));//set it to the first command line argument and turn that command line argument into an integer. System. out. println(two. gethours()); //print out the hours two. setpay(-55);//set this to whatever value u want in the setpay constructor. } catch (negativenumberexception e) {//catch the exception from worker class, i can call the negativenumberexception whatever i want, like e, ex, zebra etc.