I have a question on setters and getters and the 'this' keyword. So if I have a
Question:
I have a question on setters and getters and the 'this' keyword. So if I have a public void named public void setTime(int time), then can I have anything in the method I want like the calculations for the accleration of the object in reference to time or the height of an object at a certain time or even the user input for the int time like time = scanner.nextDouble; ? and can the getters (which I believe are called accessor methods) can anything besides a return statement in it? And I have three more questions on the keyword 'this'. I know the keyword 'this' can be used like this.time = time; which sets the instance var to the parameter, but does the parameter need to be int time? And finally, does the this.time be used in calculation like this.time + 2 = z and is there a difference in if I put this.time = time at the beginning of the method or at the end of the method after all calculations equations are added?
Accounting for Decision Making and Control
ISBN: 978-1259564550
9th edition
Authors: Jerold Zimmerman