Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,330 --> 00:00:02,460
We're going to have the first auction selling a car.
2
00:00:03,950 --> 00:00:08,660
The requirements state that a dealership can perform two auctions, sell a car and search for one.
3
00:00:10,390 --> 00:00:13,090
So in this lesson, we're going to add the selca action.
4
00:00:15,470 --> 00:00:21,410
Inside the dealership class at a method called sell public, the method is not going to return anything,
5
00:00:21,410 --> 00:00:24,950
but it needs an index parameter so that we know which car to sell.
6
00:00:30,120 --> 00:00:36,030
And selling a car implies that the customer is going to drive away with it, so we'll choose the car
7
00:00:36,030 --> 00:00:38,100
object at the index chosen by the user.
8
00:00:40,670 --> 00:00:42,170
And it needs to drive away.
9
00:00:43,500 --> 00:00:48,780
And after the car gets driven away, we need to remove it from the dealership, so set the car object
10
00:00:48,780 --> 00:00:49,770
that we just sold.
11
00:00:58,800 --> 00:00:59,700
Equal to No.
12
00:01:01,290 --> 00:01:04,730
All right, let's assume a customer came to buy the third Mesud.
13
00:01:04,920 --> 00:01:08,460
I want to stay consistent with my visuals, so we'll make this twenty seventeen.
14
00:01:09,270 --> 00:01:12,900
And now this car is in parking lot, too, so we'll sell it to them.
15
00:01:13,620 --> 00:01:17,100
Call Selca from the dealership object and pass in the index to.
16
00:01:34,950 --> 00:01:40,860
It prints them a happy message and it sells them the car driver runs the selca function, which prints
17
00:01:40,860 --> 00:01:46,890
a friendly message, setting the object at index to to know this frees up a parking space.
18
00:01:46,900 --> 00:01:48,780
And now we have room for another car.
19
00:01:50,750 --> 00:01:56,660
Also, I hope you notice how it's all starting to come together by planning our code around objets fields
20
00:01:56,660 --> 00:01:59,840
and actions, everything just fits together so smoothly.
21
00:02:00,470 --> 00:02:03,880
When I read this code, it's almost like I'm reading a story here.
22
00:02:03,890 --> 00:02:06,520
We have three cars, two Nissans and a Dodge.
23
00:02:07,040 --> 00:02:09,380
There is a dealership that owns all of these cars.
24
00:02:09,750 --> 00:02:14,720
Oh, the dealership just sold one of the cars and after selling the car, it gets driven off.
25
00:02:15,500 --> 00:02:17,210
The code is just so easy to read.
26
00:02:17,690 --> 00:02:21,140
And this is the power of object oriented programming.
27
00:02:21,560 --> 00:02:23,270
It makes your code expressive.
28
00:02:23,570 --> 00:02:29,030
And when your code is this expressive, you don't need to add comments because the code is already as
29
00:02:29,030 --> 00:02:30,110
clear as it's going to get.
30
00:02:32,260 --> 00:02:36,670
In this lesson, you added an action to your dealership class, there is one more action that we need
31
00:02:36,670 --> 00:02:38,890
to add and that is searching for a car.
3155
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.