Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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? 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Lets break down your questions In the setTime method you can perform any operations you need such as ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting for Decision Making and Control

Authors: Jerold Zimmerman

9th edition

125956455X, 978-1259564550

More Books

Students also viewed these Programming questions

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago

Question

Inattentional blindness is a product of our _______ attention.

Answered: 1 week ago