1
00:00:00,860 --> 00:00:03,860
Every class with fields needs getters and setters.

2
00:00:05,950 --> 00:00:09,130
A child class can inherit methods from its parent class.

3
00:00:11,400 --> 00:00:16,410
So in this lesson, your child class is going to inherit getters and setters from its parent class.

4
00:00:20,820 --> 00:00:26,010
We're going to use the Java code generator to generate the getters and setters, we'll do it for product.

5
00:00:33,330 --> 00:00:33,930
Pense.

6
00:00:43,260 --> 00:00:44,130
Then Schertz.

7
00:00:46,930 --> 00:00:47,620
Pretty simple.

8
00:00:53,650 --> 00:00:58,060
And now from short notice that we can automatically access so many getters and setters.

9
00:00:59,460 --> 00:01:03,160
But wait, we didn't define any of those methods in the short class.

10
00:01:03,180 --> 00:01:04,260
So where did they come from?

11
00:01:05,550 --> 00:01:11,280
These methods came from the product class because shirt and pants inherit every field and method from

12
00:01:11,280 --> 00:01:12,060
their parent.

13
00:01:17,650 --> 00:01:19,300
I'm going to get the price of the shirt.

14
00:01:22,990 --> 00:01:24,100
And run the debugger.

15
00:01:31,860 --> 00:01:35,250
The price is five ninety nine, and here I can step in to get price.

16
00:01:37,600 --> 00:01:42,970
It calls to get price method, this points to the current object that's calling this method.

17
00:01:45,620 --> 00:01:48,560
So the stock price returns the price of that object.

18
00:01:53,150 --> 00:01:56,270
Now will set the price of the pants equal to nine 999.

19
00:02:01,210 --> 00:02:02,020
Run the debugger.

20
00:02:04,560 --> 00:02:06,240
Here I can step in to set price.

21
00:02:08,860 --> 00:02:10,660
It calls the set price method.

22
00:02:12,190 --> 00:02:17,560
This points to the current object that's calling this method and we're setting the price of the current

23
00:02:17,560 --> 00:02:19,750
object equal to fifty nine ninety nine.

24
00:02:29,720 --> 00:02:34,940
A child, the class can inherit the methods from its parent class that includes getters and setters.

