PROG24178 Lecture Notes - Lecture 22: Exception Handling, Negative Number, Mutator Method

164 views7 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents