Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,240 --> 00:00:04,620
In this video, I'm going to go through part one of our final challenge, part one consisted of setting
2
00:00:04,620 --> 00:00:07,440
up a Tic-Tac taghrid by implementing two tasks.
3
00:00:08,130 --> 00:00:11,730
Task one says, to create an array with three rows of underscore characters.
4
00:00:11,940 --> 00:00:17,220
And looking back at the article, the tic tac toe board as three rows in each row has three elements.
5
00:00:19,960 --> 00:00:22,390
So back in my code, I'll say car board.
6
00:00:28,070 --> 00:00:33,560
Is equal to a new car array with three rows such that each euro has three elements.
7
00:00:37,010 --> 00:00:41,240
And you know what, I was thinking of doing a nested loop that updates every element in each row, but
8
00:00:41,240 --> 00:00:44,350
it would be easier to just initialize everything from the get go.
9
00:00:45,080 --> 00:00:48,890
So all set are variable equal to a two tier array with three rows of values.
10
00:00:56,760 --> 00:01:00,330
Such that each row stores three underscore characters.
11
00:01:15,710 --> 00:01:16,290
Beautiful.
12
00:01:16,340 --> 00:01:19,790
The next task is to print the array using a function called the print array.
13
00:01:28,490 --> 00:01:31,430
So right over here, we'll create a function that's public static.
14
00:01:33,050 --> 00:01:34,700
The function seems to be void.
15
00:01:36,580 --> 00:01:37,870
It's called print board.
16
00:01:40,080 --> 00:01:42,150
And it takes one parameter, the board.
17
00:01:46,360 --> 00:01:50,590
And inside the function, I left you some instructions which will ensure that your board prints in a
18
00:01:50,590 --> 00:01:52,600
nice format, No.
19
00:01:52,600 --> 00:01:54,970
One print a new line, simple enough.
20
00:01:57,280 --> 00:01:59,440
Now we'll say print, not print online.
21
00:02:00,000 --> 00:02:04,180
The reason I'm using print, not print online, is because print online already adds a new line for
22
00:02:04,180 --> 00:02:04,370
you.
23
00:02:04,840 --> 00:02:08,039
So putting another end is going to create two lines.
24
00:02:08,650 --> 00:02:13,750
So alternatively, you could just write print online with nothing inside, but I find that kind of weird.
25
00:02:17,100 --> 00:02:19,560
Anyways, the next step is to print the board.
26
00:02:19,710 --> 00:02:25,590
This requires a nested loop, we start with the outer loop or the Roman next is going to start at Rosero.
27
00:02:28,390 --> 00:02:32,980
And it's going to keep running as long as the ROE index is less than the length of our 2D array.
28
00:02:33,280 --> 00:02:37,070
In other words, as long as it's less than the number of rows I.
29
00:02:37,090 --> 00:02:37,870
Plus plus.
30
00:02:43,110 --> 00:02:46,050
And the inner loop is going to start at the first element in that row.
31
00:02:48,950 --> 00:02:50,130
J equals zero.
32
00:02:50,630 --> 00:02:54,170
It's going to keep running until J indexes every element in that row.
33
00:03:00,960 --> 00:03:02,010
J plus plus.
34
00:03:05,800 --> 00:03:09,490
And inside the inner loop, we can print the contents of our 2D array.
35
00:03:13,960 --> 00:03:16,210
The first bracket is going to index each row.
36
00:03:19,450 --> 00:03:22,400
And the second one indexes every element in that row.
37
00:03:23,320 --> 00:03:27,730
I know we're not done yet, but before we finish coding the logic inside Prince Board, it's a good
38
00:03:27,730 --> 00:03:32,560
idea to keep testing your code as you update it, because you never know when a bug is going to find
39
00:03:32,560 --> 00:03:33,660
its way into your code.
40
00:03:34,210 --> 00:03:39,160
So I'm going to call the function passing that to drasin argument.
41
00:03:41,540 --> 00:03:42,290
Run the code.
42
00:03:51,400 --> 00:03:56,860
And so far, everything works, but every Dasch character on your score, I should say, prince on the
43
00:03:56,860 --> 00:03:57,550
same line.
44
00:04:02,820 --> 00:04:07,590
Looking back at the instructions, it says, to separate each row by two lines of space.
45
00:04:13,920 --> 00:04:18,420
So after the inner loop runs through an entire row, we're going to print two lines.
46
00:04:32,160 --> 00:04:37,890
Then it says that each row proceeds a tab of space, so before printing each row, we need to add a
47
00:04:37,890 --> 00:04:39,000
tab of spacing.
48
00:04:48,060 --> 00:04:48,900
Run the code.
49
00:05:00,580 --> 00:05:03,700
There is your type of spacing that gets printed before each row.
50
00:05:08,050 --> 00:05:11,130
And notice that each arrow is separated by two empty lines.
51
00:05:21,070 --> 00:05:25,330
And the last step says that each character in the grid has one space from the other character.
52
00:05:26,720 --> 00:05:27,740
We can do just that.
53
00:05:35,220 --> 00:05:36,270
Rewriting, running the code.
54
00:05:39,870 --> 00:05:42,030
And I think it's safe to say that we're done.
55
00:05:42,840 --> 00:05:45,290
I hope I clarified any problems you had with part one.
56
00:05:45,720 --> 00:05:46,820
Good luck on part two.
57
00:05:46,830 --> 00:05:48,170
I hope you figure it out.
5403
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.