Every class with fields needs getters and setters.
A child class can inherit methods from its parent class.
So in this lesson, your child class is going to inherit getters and setters from its parent class.
We're going to use the Java code generator to generate the getters and setters, we'll do it for product.
Pense.
Then Schertz.
Pretty simple.
And now from short notice that we can automatically access so many getters and setters.
But wait, we didn't define any of those methods in the short class.
So where did they come from?
These methods came from the product class because shirt and pants inherit every field and method from
their parent.
I'm going to get the price of the shirt.
And run the debugger.
The price is five ninety nine, and here I can step in to get price.
It calls to get price method, this points to the current object that's calling this method.
So the stock price returns the price of that object.
Now will set the price of the pants equal to nine 999.
Run the debugger.
Here I can step in to set price.
It calls the set price method.
This points to the current object that's calling this method and we're setting the price of the current
object equal to fifty nine ninety nine.
A child, the class can inherit the methods from its parent class that includes getters and setters.