Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,570 --> 00:00:05,910
There is only one more class we have to write up, and it's the store, the store divides into aisles,
2
00:00:05,910 --> 00:00:08,800
into rows, and each row has many items.
3
00:00:09,150 --> 00:00:13,200
So right there, we already know that we need to store items using a tuti array.
4
00:00:16,740 --> 00:00:22,500
And we're going to call the two day right items and as always, if a class has fields, you need to
5
00:00:22,500 --> 00:00:26,550
apply the big three steps, a constructor, a getter and a setter constructor.
6
00:00:26,670 --> 00:00:30,630
Public shares the same name as the class receives no parameters.
7
00:00:33,330 --> 00:00:37,950
Because in the beginning, her story is going to be empty and we're just going to set the field equal
8
00:00:37,950 --> 00:00:43,170
to a new to the array of item objects with seven arrows and three columns.
9
00:00:50,750 --> 00:00:52,130
Now we want to add a her.
10
00:00:55,620 --> 00:01:03,810
That receives two parameters into row and column, and it's going to return an object of the item class.
11
00:01:06,140 --> 00:01:08,810
At the request, the row and column.
12
00:01:16,360 --> 00:01:19,960
Now we want to add a setter that receives three parameters.
13
00:01:22,860 --> 00:01:23,730
Entero.
14
00:01:25,720 --> 00:01:26,710
And Colin.
15
00:01:29,010 --> 00:01:34,500
And the item we're going to use to update the story and it's going to update the element at the request
16
00:01:34,500 --> 00:01:35,490
of the Roon column.
17
00:01:40,470 --> 00:01:43,530
Equal to a new copy of the item object that was passed on.
18
00:01:46,990 --> 00:01:50,800
All right, now, before adding the two string method, we're just going to set up some code and main.
19
00:01:53,100 --> 00:01:54,870
First, remove what you have in main.
20
00:01:57,980 --> 00:02:01,070
And copy the tutelary from the article that I left you.
21
00:02:19,940 --> 00:02:22,470
Then create an object of the store class.
22
00:02:24,200 --> 00:02:27,410
Store store is equal to a new object of the store class.
23
00:02:29,910 --> 00:02:33,480
And we need to populate the store with every item from the tutera.
24
00:02:34,600 --> 00:02:37,720
The outer loop counter I is going to index every row.
25
00:02:39,220 --> 00:02:43,600
And the inner loop countered, Jay is going to index every element and I.
26
00:02:47,070 --> 00:02:50,430
And then we can update the stories extorts, said Eitam.
27
00:02:55,170 --> 00:03:00,150
With every item from Rowby and column J of the inventory to the array.
28
00:03:11,150 --> 00:03:16,020
We've written a lot of code and it would be a good idea to test it before moving on, so we've launched
29
00:03:16,040 --> 00:03:16,670
a debugger.
30
00:03:21,470 --> 00:03:23,510
I as zero zero.
31
00:03:28,470 --> 00:03:36,060
It updates the element at Index zero zero, Nimmi zero Jazz one, it updates the element at index zero
32
00:03:36,060 --> 00:03:36,450
one.
33
00:03:41,850 --> 00:03:43,790
OK, I'm pretty confident it's going to work.
34
00:03:49,180 --> 00:03:52,090
Anyways, now we want to add the two string method.
35
00:03:54,020 --> 00:03:56,360
As always, public string to string.
36
00:04:01,830 --> 00:04:05,260
First, we set a string variable temp that equals an empty string.
37
00:04:05,290 --> 00:04:06,390
Then we return it's.
38
00:04:12,110 --> 00:04:17,089
Then I'm going to create a loop that runs through every item in the items array and as the outer loop
39
00:04:17,089 --> 00:04:23,420
counter I indexes every row, the inner loop countered J is going to index every single element in a
40
00:04:23,420 --> 00:04:24,290
row I.
41
00:04:28,790 --> 00:04:36,170
Then I can grab every single element I and element, just grab the two string of that item and add it
42
00:04:36,170 --> 00:04:37,100
to the string.
43
00:04:43,010 --> 00:04:46,610
And then back in Maine, I'm going to grab the following print statements from the article.
44
00:05:04,760 --> 00:05:10,430
And OK, we're looking good, riggi to separate each row into its own line because every row prints
45
00:05:10,430 --> 00:05:11,270
on the same one.
46
00:05:13,410 --> 00:05:19,140
So after the inner loop runs through an entire row, I'm going to add two lines, separators to temp.
47
00:05:33,460 --> 00:05:35,250
And this is shaping up really well.
48
00:05:42,590 --> 00:05:45,680
Back in the article, it tells us that this switch statement.
49
00:05:48,040 --> 00:05:54,100
If you look at the output, each I'll name is printed before the inner loop prints an entire row of
50
00:05:54,100 --> 00:05:54,560
data.
51
00:05:54,940 --> 00:05:58,600
So that means you need to add a switch statement right before the inner loop.
52
00:06:14,890 --> 00:06:20,230
And it works perfectly every time the outer loop runs at Prince, one of the strings, depending on
53
00:06:20,230 --> 00:06:21,730
what the outer loop indexes.
54
00:06:23,940 --> 00:06:26,970
And then the inner loop prince, an entire row of data.
55
00:06:28,700 --> 00:06:35,990
This process repeats seven times, which results in seven aisles of product being printed, by all means,
56
00:06:35,990 --> 00:06:38,680
feel free to add breakpoints and visualize the runtime.
57
00:06:38,690 --> 00:06:39,980
It can be really satisfying.
58
00:06:42,160 --> 00:06:47,290
And the last thing we want to do, which is purely for static reasons, is to add some stars at the
59
00:06:47,290 --> 00:06:48,450
very end of the string.
60
00:06:48,640 --> 00:06:53,320
So right after the nested loop runs to completion, we can append the closing stars.
61
00:07:04,090 --> 00:07:05,170
And voila.
5942
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.