Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,670 --> 00:00:02,560
Objects can perform actions.
2
00:00:05,910 --> 00:00:11,730
Fields work together to describe an object, a car as described by its milk price, year and color,
3
00:00:12,510 --> 00:00:15,530
and based on the requirements, a car can also perform one action.
4
00:00:15,540 --> 00:00:16,320
It can drive.
5
00:00:19,220 --> 00:00:22,160
In this lesson, you're going to have to drive action to the car class.
6
00:00:25,650 --> 00:00:32,220
So what is an action, an action is a method, a function, an action is a method that represents what
7
00:00:32,220 --> 00:00:33,330
the object can do.
8
00:00:35,120 --> 00:00:40,730
From the requirements, we found that a car can perform the drive action, so we need to drive action
9
00:00:40,730 --> 00:00:41,690
to the car class.
10
00:00:44,240 --> 00:00:49,790
So in the car class at a method called drive public, the method is not going to return anything.
11
00:00:50,240 --> 00:00:53,870
It's called drive and it's not going to receive any parameters.
12
00:00:58,430 --> 00:01:03,710
All right, now, every car object that you make from the car class can call the drive method pretty
13
00:01:03,710 --> 00:01:03,950
cool.
14
00:01:07,030 --> 00:01:11,330
And the drive method is going to print every field from the object that calls it as part of a nice string.
15
00:01:11,830 --> 00:01:13,000
So we're going to print line.
16
00:01:13,360 --> 00:01:14,590
You bought the beautiful.
17
00:01:20,180 --> 00:01:21,140
This year.
18
00:01:25,750 --> 00:01:26,800
Add some space.
19
00:01:31,610 --> 00:01:32,630
This color.
20
00:01:39,280 --> 00:01:40,450
Add some more space.
21
00:01:44,900 --> 00:01:47,300
And print the make field of the current object.
22
00:01:51,350 --> 00:01:52,550
And then we'll say for.
23
00:01:55,140 --> 00:01:56,910
The price of the current object.
24
00:02:09,900 --> 00:02:13,740
And after that, we'll say, please drive your car to the nearest exit.
25
00:02:21,990 --> 00:02:23,130
Followed by a new line.
26
00:02:29,190 --> 00:02:33,450
OK, I think it's time to remove these print statements, and I'm going to call the drive action from
27
00:02:33,450 --> 00:02:34,590
the Nissan object.
28
00:02:59,680 --> 00:03:03,670
And sure enough, it prints every field and the car essentially drives.
29
00:03:06,080 --> 00:03:09,840
The object caused the drive method, Jabor runs the drive method.
30
00:03:10,220 --> 00:03:16,370
This points to the current object that's calling the method and the method prints every field that describes
31
00:03:16,370 --> 00:03:17,590
the current object.
32
00:03:21,900 --> 00:03:24,000
I'm going to call this method from every object.
33
00:03:46,410 --> 00:03:49,800
And sure enough, it prints every field from the object that calls it.
34
00:03:58,120 --> 00:04:03,250
In this lesson, you added an action to your car class, an action describes what the object can do,
35
00:04:03,800 --> 00:04:06,010
the requirements tell us that a car can drive.
36
00:04:08,120 --> 00:04:13,490
So you added a drive method to the car class and now every car object can call that action.
37
00:04:17,450 --> 00:04:22,850
And when called, it essentially prints every field that describes the current object as part of a nice
38
00:04:22,850 --> 00:04:23,390
string.
3490
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.