Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,460 --> 00:00:04,780
In the last section, we started working through our dart program design flow here, that's hopefully
2
00:00:04,780 --> 00:00:08,210
going to give us a reasonable design for our application.
3
00:00:08,800 --> 00:00:13,330
We went through step one and we ended up saying that we're going to have two classes inside of application
4
00:00:13,690 --> 00:00:17,890
one to represent a single card and then one to represent a collection of cards.
5
00:00:18,840 --> 00:00:22,800
We're not going to move on to step two, where we're going to think about the different properties or
6
00:00:22,800 --> 00:00:25,940
fields that are going to belong to each of these classes.
7
00:00:26,430 --> 00:00:31,770
So we need to begin by thinking about the different pieces of data that should be tied to each of the
8
00:00:31,770 --> 00:00:33,400
things that exist inside of rap.
9
00:00:34,170 --> 00:00:37,650
Now, I'm going to go back over to my diagram of our deck of cards over here.
10
00:00:37,830 --> 00:00:42,360
And we'll first begin by thinking about the different fields or properties that should belong to an
11
00:00:42,360 --> 00:00:43,820
individual cart.
12
00:00:43,830 --> 00:00:46,110
So specifically the card class.
13
00:00:46,840 --> 00:00:51,700
So I'm going to drag a card down here just so we can study it in great detail by itself.
14
00:00:52,440 --> 00:00:57,630
So as I look at this individual card, I can really only think of two properties that should belong
15
00:00:57,630 --> 00:00:58,140
to this thing.
16
00:00:58,650 --> 00:01:02,510
The first is the rank of the card, in this case, Ace.
17
00:01:03,030 --> 00:01:08,550
So the rank of a card would be like ACE two, three, four, five, six, seven, all the way up to
18
00:01:08,550 --> 00:01:11,970
ten, Jack King, Queen and so on.
19
00:01:12,900 --> 00:01:16,380
The other property that I think this should have should be the suit as well.
20
00:01:16,830 --> 00:01:20,070
So is this a card of diamonds or of spades?
21
00:01:20,070 --> 00:01:21,230
Of hearts of clubs?
22
00:01:21,960 --> 00:01:28,410
So in total, I think that our card class will have two properties associated with it, the rank right
23
00:01:28,410 --> 00:01:30,180
here in the suit right here.
24
00:01:30,780 --> 00:01:34,980
The other thing I want to mention is I think both of these fields will be of type string.
25
00:01:35,410 --> 00:01:36,660
I think that makes a lot of sense.
26
00:01:36,660 --> 00:01:41,610
In the case of the suit right here, we should store a string of like literally diamonds.
27
00:01:42,000 --> 00:01:45,720
In the case of the ring, you could definitely make a case for saying that we should store that as an
28
00:01:45,720 --> 00:01:51,880
integer where one would represent an ace and then maybe 11 would be Jack Queen would be 12.
29
00:01:52,500 --> 00:01:53,220
Am I doing that right?
30
00:01:53,250 --> 00:01:54,570
Yes, King would be 13.
31
00:01:56,850 --> 00:02:01,290
But I think that in this case, just using a string to indicate the rank makes a lot of sense as well,
32
00:02:01,290 --> 00:02:05,550
because the end goal here is going to be us wanting to actually print out some information about these
33
00:02:05,550 --> 00:02:10,770
cards in would definitely make a lot more sense to display that as a simple as queen king rather than
34
00:02:10,770 --> 00:02:12,210
having to deal with some integers.
35
00:02:13,020 --> 00:02:15,780
OK, so I think that takes care of the individual cards.
36
00:02:16,260 --> 00:02:21,000
Now, the other class we have to think about is the collection of fields or the different properties
37
00:02:21,150 --> 00:02:23,360
that's going to belong to the deck class.
38
00:02:24,090 --> 00:02:29,580
Remember that we had just said that an individual card doesn't make a lot of sense by itself.
39
00:02:29,860 --> 00:02:35,430
It's only when we combine together a bunch of cards into a deck that we start getting a interesting
40
00:02:35,430 --> 00:02:37,680
application and we can actually make a game out of it.
41
00:02:38,400 --> 00:02:45,210
So I think that for the properties that belongs to the deck, we'll probably just have one single property
42
00:02:45,210 --> 00:02:46,440
or one single field.
43
00:02:46,680 --> 00:02:50,870
And that will be a list of cards exactly as you see right here.
44
00:02:51,570 --> 00:02:59,070
So every deck instance inside of our application will have a collection of card instances somehow associated
45
00:02:59,070 --> 00:02:59,520
with it.
46
00:03:00,710 --> 00:03:05,060
OK, so let's take these kind of decisions about our design, we're going to go back over to our design
47
00:03:05,060 --> 00:03:05,660
flow here.
48
00:03:06,260 --> 00:03:07,610
So we just did this thing right here.
49
00:03:07,610 --> 00:03:10,910
We thought about the different pieces of data that should be attached to each thing.
50
00:03:11,300 --> 00:03:16,570
We're now going to want to create a field on each class that's going to hold that type of data.
51
00:03:17,210 --> 00:03:20,780
And one other thing I want to look at very quickly is just a summary of what we're deciding at this
52
00:03:20,780 --> 00:03:21,140
point.
53
00:03:21,530 --> 00:03:26,900
So for the card class, we're going to have a suit of type string and a rank of type type string.
54
00:03:27,930 --> 00:03:33,240
Then for the DECLASSE, we're going to have a cards property, so this card's property right here is
55
00:03:33,240 --> 00:03:36,960
going to reflect all the different cards that belong to this particular deck.
56
00:03:37,440 --> 00:03:40,470
And it's going to be of type list of cards.
57
00:03:40,930 --> 00:03:46,560
I want to very quickly zoom in on this, because the syntax I used here is actually somewhat important
58
00:03:47,220 --> 00:03:48,600
because I'm going to blow up the text here.
59
00:03:49,730 --> 00:03:51,240
Let's do thirty six.
60
00:03:51,260 --> 00:03:51,730
There we go.
61
00:03:53,410 --> 00:03:57,800
So the syntax I used here to indicate this type is something that we're going to see inside of our dark
62
00:03:57,820 --> 00:03:58,510
code as well.
63
00:03:59,050 --> 00:04:07,480
This means that the cards property over here should be a value of type list that contains only instances
64
00:04:07,480 --> 00:04:08,460
of cards.
65
00:04:09,130 --> 00:04:13,630
So that kind of little Brace's right here, brackets that you see right here means to say that inside
66
00:04:13,630 --> 00:04:17,019
this list, we're just going to have values of Type Kaat.
67
00:04:17,970 --> 00:04:21,779
The other thing I want to mention is what this list right thing right here is as well.
68
00:04:21,930 --> 00:04:26,300
So in dirt, we have a kind of but we don't call them arrays.
69
00:04:26,610 --> 00:04:28,750
Instead, we call them lists.
70
00:04:29,310 --> 00:04:35,930
So when we say list of cards right here, you can also think of this as being like an array of cards,
71
00:04:36,120 --> 00:04:37,020
same type of thing.
72
00:04:37,660 --> 00:04:42,990
But to actually list that out or to actually designate that we would write list and then card inside
73
00:04:42,990 --> 00:04:44,100
of the braces.
74
00:04:45,110 --> 00:04:50,000
OK, so let's now flip back over to pad and we're going to add on these fields to our program.
75
00:04:51,370 --> 00:04:56,680
So we'll go back over to D'Arte Pad, here we go, and then remember the syntax that we use for adding
76
00:04:56,680 --> 00:05:01,510
fields to a class, we write out the type that we want to add to it.
77
00:05:01,690 --> 00:05:06,030
So in this case, I'm going to add a string and then the name of the field.
78
00:05:06,790 --> 00:05:11,970
So for the card, we're going to deal with a suit and we're going to have a string of Reinke as well.
79
00:05:13,920 --> 00:05:16,160
Then for the deck, we're going to do the same thing.
80
00:05:17,740 --> 00:05:23,380
Now, in this case, we want to say that we're going to have a type of list with cards inside of that,
81
00:05:23,620 --> 00:05:30,640
so to indicate that type on our class right here, we can write out list card and then cards.
82
00:05:31,210 --> 00:05:36,400
So just the same as what we did right here where we put down the name of or the type of the property
83
00:05:36,400 --> 00:05:37,600
and then the name of the property.
84
00:05:37,840 --> 00:05:39,940
We did the exact same thing up here as well.
85
00:05:40,360 --> 00:05:45,790
So the name of the property is going to be cards and it's going to be of type list containing nothing
86
00:05:45,790 --> 00:05:46,570
but cards.
87
00:05:47,730 --> 00:05:50,620
OK, so we just got through step two of our design flow here.
88
00:05:51,030 --> 00:05:55,380
Let's come back to the next section and we're going to start thinking about adding methods to represent
89
00:05:55,380 --> 00:05:56,850
each of these classes.
90
00:05:56,880 --> 00:05:59,210
So quick break and I'll see you in just a minute.
9082
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.