1
00:00:08,790 --> 00:00:11,670
So this lecture is really, an opportunity
for us to

2
00:00:11,670 --> 00:00:15,350
walk through the big ideas, that you
should have learned

3
00:00:15,350 --> 00:00:18,990
over the course of this Coursera course,
to make sure,

4
00:00:18,990 --> 00:00:22,860
you've got the big concepts before you
take the final exam.

5
00:00:22,860 --> 00:00:27,830
So these are not in-lecture quizzes,
because these are serious.

6
00:00:27,830 --> 00:00:30,810
They're not intended to just be funny,
well,

7
00:00:30,810 --> 00:00:33,260
as I've said before like I think is funny.

8
00:00:33,260 --> 00:00:33,710
So,

9
00:00:33,710 --> 00:00:36,360
really these are questions for you to
reflect

10
00:00:36,360 --> 00:00:39,270
on, how well you think you understand a

11
00:00:39,270 --> 00:00:41,510
set of topics that I'm going to provide

12
00:00:41,510 --> 00:00:44,610
to you over the course of this Powerpoint
show.

13
00:00:44,610 --> 00:00:50,270
So, for all of these questions, you should
think about on a scale of

14
00:00:50,270 --> 00:00:55,690
none to excellent, how well you understand
that particular topic.

15
00:00:58,000 --> 00:01:01,880
For example, for this first one, do you
understand the difference

16
00:01:01,880 --> 00:01:07,150
between what variables and fields are, for
and what methods are for?

17
00:01:07,150 --> 00:01:12,510
So this comes back to the core idea,
behind object oriented programming.

18
00:01:12,510 --> 00:01:17,840
Where we store data, state information in
fields and then

19
00:01:17,840 --> 00:01:23,740
we provide behavior, from classes by
implementing methods for those classes.

20
00:01:23,740 --> 00:01:28,760
So that's sort of the core idea here, the
difference between the data and the

21
00:01:28,760 --> 00:01:34,120
behavior and remember encapsulation, puts
both the data and the behavior,

22
00:01:34,120 --> 00:01:39,310
into a single thing, a capsule, the class
that you can then use.

23
00:01:42,970 --> 00:01:47,940
Understanding that we need to declare and
initialize variables before we use them.

24
00:01:47,940 --> 00:01:51,110
We've been doing this all along, right, we
declare variables,

25
00:01:51,110 --> 00:01:54,600
to reserve that space in memory and we
provide a data

26
00:01:54,600 --> 00:01:59,000
type so that the compiler knows, how much
space to set

27
00:01:59,000 --> 00:02:04,020
aside and what operations will be valid,
on those particular variables.

28
00:02:04,020 --> 00:02:08,340
And we need to initialize them certainly,
give them a value, before we use them,

29
00:02:08,340 --> 00:02:12,890
whether that means assign zero to a score
that the player's going to

30
00:02:12,890 --> 00:02:18,450
have, or create a new object for a texture
to defield, for example.

31
00:02:18,450 --> 00:02:21,260
But we need to somehow, initialize the
value of

32
00:02:21,260 --> 00:02:23,860
that variable, before we actually try to
use it.

33
00:02:27,660 --> 00:02:32,320
So here's a core idea behind the type
system in C#.

34
00:02:32,320 --> 00:02:37,660
We have value types, that we talked about
very early on, way back in Module 3.

35
00:02:37,660 --> 00:02:43,160
And those are the predefined types in
general, don't include string,

36
00:02:43,160 --> 00:02:48,120
but the predefined types in general, that
for

37
00:02:48,120 --> 00:02:52,890
the space and memory, that's reserved for
that variable, it holds the value

38
00:02:52,890 --> 00:02:54,580
of that variable.

39
00:02:54,580 --> 00:02:57,990
As opposed to, reference types, that hold
a

40
00:02:57,990 --> 00:03:02,040
reference to an object somewhere else in
memory.

41
00:03:02,040 --> 00:03:06,810
Such that the value of a reference type
variable, is

42
00:03:06,810 --> 00:03:10,590
not the actual object, it's a reference to
the object.

43
00:03:10,590 --> 00:03:12,870
And if you want to think of that as the
memory address of

44
00:03:12,870 --> 00:03:17,330
the object, that's fine because that's
close enough, for this particular course.

45
00:03:21,780 --> 00:03:26,290
Another core idea behind object oriented,
the object oriented

46
00:03:26,290 --> 00:03:30,650
paradigm, is the different between the
class and the object.

47
00:03:30,650 --> 00:03:35,570
So as we know, because we've been using
classes and objects since module four.

48
00:03:35,570 --> 00:03:41,750
As we know the class is the template, that
expresses what data will be stored

49
00:03:41,750 --> 00:03:46,980
in a particular object, that is
instantiated for that class and

50
00:03:46,980 --> 00:03:51,920
the behaviors are the methods that an
object of that class, exposes.

51
00:03:51,920 --> 00:03:55,230
So the class is the template or the cookie
cutter,

52
00:03:55,230 --> 00:03:59,620
and the objects are the things we produce,
the cookies.

53
00:04:04,160 --> 00:04:09,770
So how to implement and call methods?
Is again, you, I

54
00:04:09,770 --> 00:04:14,520
mean, our very first C# program, you were
calling the console right line method.

55
00:04:14,520 --> 00:04:18,290
So calling methods, we understand that if
it's an

56
00:04:18,290 --> 00:04:21,240
instance method, which is sort of what we
use most

57
00:04:21,240 --> 00:04:25,250
commonly, we have the name of an object,
variable, a

58
00:04:25,250 --> 00:04:29,170
reference type variable, dot and the
method name, and then

59
00:04:29,170 --> 00:04:32,300
between parentheses we provide whatever
arguments are required.

60
00:04:33,720 --> 00:04:37,720
For those less common but still used a lot

61
00:04:37,720 --> 00:04:39,950
methods, static methods, we put the
console, sorry the console

62
00:04:39,950 --> 00:04:40,100
[LAUGH]

63
00:04:40,100 --> 00:04:40,600
we put the

64
00:04:43,110 --> 00:04:46,580
class name, followed by the dot, followed
by the method

65
00:04:46,580 --> 00:04:51,590
name, followed by, between parenthesis,
whatever arguments we need to provide.

66
00:04:51,590 --> 00:04:54,610
So that's calling the different kinds of
methods

67
00:04:54,610 --> 00:04:57,620
and we also know, that methods can return

68
00:04:57,620 --> 00:05:01,210
either void, or something like a card,
when

69
00:05:01,210 --> 00:05:02,810
we we're taking the top card from a deck.

70
00:05:04,280 --> 00:05:08,950
And so, in most cases, we're going to want
to store

71
00:05:08,950 --> 00:05:13,280
that information that gets returned
somehow, even if we

72
00:05:13,280 --> 00:05:17,760
directly pass it, as an argument to a new
method.

73
00:05:17,760 --> 00:05:19,900
So for example in the blackjack game,
where

74
00:05:19,900 --> 00:05:22,740
you would call the add card method on

75
00:05:22,740 --> 00:05:29,040
the blackjack hand object, and one of your
arguments could be deck dot take top card.

76
00:05:29,040 --> 00:05:31,200
That means we weren't throwing away the
card, that got

77
00:05:31,200 --> 00:05:34,570
returned from that method, we were just
passing it along.

78
00:05:34,570 --> 00:05:37,240
And so when we call methods that return
something

79
00:05:37,240 --> 00:05:40,100
other than void, we have a decision to
make,

80
00:05:40,100 --> 00:05:42,100
about whether or not to store or use that

81
00:05:42,100 --> 00:05:45,030
information that gets returned, and
usually the answer is yes.

82
00:05:46,050 --> 00:05:48,780
Implementing methods is something that we
did in

83
00:05:48,780 --> 00:05:51,920
module 11, when we implemented the role
method for

84
00:05:51,920 --> 00:05:54,080
the dice class, and when we implemented
the

85
00:05:54,080 --> 00:05:57,120
draw and update methods for our rubber
chicken class.

86
00:06:01,100 --> 00:06:07,080
So how do we use these predefined types
that are available to us in C#?

87
00:06:07,080 --> 00:06:10,030
Well, we've been doing this for a long
time, right?

88
00:06:10,030 --> 00:06:15,480
So these are the value types, I guess
that's a little strong, right?

89
00:06:15,480 --> 00:06:18,100
So let's say, the predefined types in C#

90
00:06:18,100 --> 00:06:20,670
in the XNA framework, because you should
also

91
00:06:20,670 --> 00:06:26,330
understand how to use a texture 2d, for
example, or a rectangle, or a vector 2.

92
00:06:26,330 --> 00:06:30,282
So those are predefined, in terms of the
framework in which we

93
00:06:30,282 --> 00:06:35,660
been working, even if they're not
predefined by the C# programming language.

94
00:06:35,660 --> 00:06:37,150
So you should understand how you declare

95
00:06:37,150 --> 00:06:39,370
variables of these types, if they happen
to

96
00:06:39,370 --> 00:06:43,500
have operations like rectangles do
methods, you should

97
00:06:43,500 --> 00:06:45,589
be able to use those methods as well.

98
00:06:49,500 --> 00:06:51,150
We spent a little bit of time talking

99
00:06:51,150 --> 00:06:54,650
about string processing, and how we could
use index

100
00:06:54,650 --> 00:06:57,880
of and substring, and we didn't actually
use

101
00:06:57,880 --> 00:07:00,740
last index of, but that's commonly used as
well.

102
00:07:00,740 --> 00:07:02,680
And you should make sure you remember,

103
00:07:02,680 --> 00:07:06,420
how you can use those string processing
operations,

104
00:07:06,420 --> 00:07:09,440
to do interesting things, like extract the
values

105
00:07:09,440 --> 00:07:12,390
from a comma separated value string, for
example.

106
00:07:16,230 --> 00:07:21,150
We talked about selection, how our
programs can make decisions, and how

107
00:07:21,150 --> 00:07:26,080
those decisions are either based on
Boolean expressions, for if statements, or

108
00:07:26,080 --> 00:07:32,330
the value of a particular variable or an
expression, for switch statements.

109
00:07:32,330 --> 00:07:37,460
And you should understand that, you should
understand both that, those, statements

110
00:07:37,460 --> 00:07:41,180
are for making decisions and how you can
actually use those statements,

111
00:07:41,180 --> 00:07:42,980
to make decisions.

112
00:07:42,980 --> 00:07:46,080
So remember, we have the sequence control
structure,

113
00:07:46,080 --> 00:07:48,190
where we just do one thing after another.

114
00:07:48,190 --> 00:07:51,860
We have the selection control structure,
where we can make decisions.

115
00:07:51,860 --> 00:07:57,260
And we have the iteration control
structure, where we loop or iterate over

116
00:07:57,260 --> 00:08:02,363
the loop body, a certain number of times
for four and for-each

117
00:08:02,363 --> 00:08:06,880
loops, or while some condition is true,
for while loops.

118
00:08:09,940 --> 00:08:13,520
You should know how to do console input
and output.

119
00:08:13,520 --> 00:08:19,170
Console output was console write line;
console input was console read line.

120
00:08:19,170 --> 00:08:22,260
And remember, sometimes we will read in
information from

121
00:08:22,260 --> 00:08:24,910
the user, that we need to convert to a
different

122
00:08:24,910 --> 00:08:27,420
data type, and that's when we use things
like,

123
00:08:27,420 --> 00:08:30,530
int dot parse or float dot parse, and so
on.

124
00:08:34,210 --> 00:08:38,780
We talked about arrays, as a good way to
store, a

125
00:08:38,780 --> 00:08:43,260
set of elements, that are all of the same
data type.

126
00:08:43,260 --> 00:08:48,390
And so you should understand, how we
declare arrays, how we use arrays,

127
00:08:48,390 --> 00:08:53,160
how we can use the index to access a
particular element of an array.

128
00:08:53,160 --> 00:08:56,040
And, how we commonly use for loops and for

129
00:08:56,040 --> 00:08:59,590
each loops, to process in some way, each
element

130
00:08:59,590 --> 00:09:00,170
of an array.

131
00:09:01,350 --> 00:09:05,570
Similarly, you should understand how
collection classes

132
00:09:05,570 --> 00:09:07,110
work, and really, just the list class.

133
00:09:07,110 --> 00:09:10,202
I won't throw one of the other collection
classes at you,

134
00:09:10,202 --> 00:09:14,000
on the final exam or anything, just the
list class is fine.

135
00:09:14,000 --> 00:09:18,500
But understand, the key difference between
arrays and lists, are that the lists can

136
00:09:18,500 --> 00:09:24,640
dynamically grow and shrink while arrays
can't and other than that,

137
00:09:24,640 --> 00:09:26,970
they have very similar capabilities.

138
00:09:26,970 --> 00:09:32,220
We tend to use collection classes, most in
our C# programs but

139
00:09:32,220 --> 00:09:36,910
because almost every modern programming
language has arrays, we covered both of

140
00:09:40,830 --> 00:09:41,130
them.

141
00:09:41,130 --> 00:09:43,070
And even though I interspersed it
throughout

142
00:09:43,070 --> 00:09:45,500
the course, we covered XNA as well.

143
00:09:45,500 --> 00:09:47,720
So you should understand the kinds of
things

144
00:09:47,720 --> 00:09:51,400
we do in the XNA load content method, and

145
00:09:51,400 --> 00:09:54,320
how the update and draw methods relate to

146
00:09:54,320 --> 00:09:57,450
each other, in the context of the game
loop.

147
00:09:57,450 --> 00:10:02,090
So we update and then draw, and update and
then draw, and so on.

148
00:10:02,090 --> 00:10:04,150
And that you should only do appropriate
things

149
00:10:04,150 --> 00:10:06,280
in the appropriate methods, you should
never draw

150
00:10:06,280 --> 00:10:09,240
anything in the update method, you should
never try to get the

151
00:10:09,240 --> 00:10:13,450
mouse state, while you're in the draw
method, those kinds of things.

152
00:10:13,450 --> 00:10:19,480
We also added some functionality into the
constructor, usually setting the window

153
00:10:19,480 --> 00:10:23,980
resolution for our game and occasionally,
making the mouse visible as well.

154
00:10:27,550 --> 00:10:32,820
We also, early on, we just used draw
rectangles to draw stuff, and

155
00:10:32,820 --> 00:10:37,380
then later, we started using source
rectangles as well, so that we could use

156
00:10:37,380 --> 00:10:43,900
sprite strips to do things like, highlight
or un-highlight a button or play

157
00:10:43,900 --> 00:10:46,520
an explosion animation, by moving the
source

158
00:10:46,520 --> 00:10:49,970
rectangle across the sprite strip as
appropriate.

159
00:10:49,970 --> 00:10:52,840
You should understand how to use both,
draw

160
00:10:52,840 --> 00:10:56,180
and source rectangles, when you draw
things in XNA.

161
00:10:59,920 --> 00:11:04,620
We also, at the very end of the course, we
learn how we can also draw strings.

162
00:11:04,620 --> 00:11:06,660
So you should understand how we use a
sprite

163
00:11:06,660 --> 00:11:09,820
font, to actually draw a string, and the
fact that

164
00:11:09,820 --> 00:11:12,280
we call the draw string method, rather
then the

165
00:11:12,280 --> 00:11:15,589
draw method, on a sprite batch object, to
do it.

166
00:11:19,250 --> 00:11:23,460
And then we actually let the player
interact with the game.

167
00:11:23,460 --> 00:11:25,950
So we learned how we could get mouse

168
00:11:25,950 --> 00:11:29,260
input, by capturing the current state of
the

169
00:11:29,260 --> 00:11:33,230
mouse, calling the mouse, get state
method, and

170
00:11:33,230 --> 00:11:34,390
then what we can do with the mouse.

171
00:11:34,390 --> 00:11:37,460
How we could process the buttons on the
mouse or use the

172
00:11:37,460 --> 00:11:40,770
x and y to drag things around on the
screen and so on.

173
00:11:41,920 --> 00:11:44,850
Even do things like highlight the quit
button,

174
00:11:44,850 --> 00:11:48,120
when we were using the quit button too,
because we could

175
00:11:48,120 --> 00:11:51,410
use the location of the mouse, to
determine when it was over

176
00:11:51,410 --> 00:11:57,680
that button, for example, same thing with
the required project, where

177
00:11:57,680 --> 00:12:01,180
you would highlight the number tiles when
the mouse was over them.

178
00:12:01,180 --> 00:12:04,250
That was based on knowing, where the mouse
was,

179
00:12:04,250 --> 00:12:08,170
relative to the draw rectangle for a
particular number tile.

180
00:12:08,170 --> 00:12:10,070
So you should understand how we can do
that

181
00:12:10,070 --> 00:12:11,220
input with a mouse.

182
00:12:14,170 --> 00:12:18,680
Similarly you should understand, how we
did the gamepad input, it's okay if you

183
00:12:18,680 --> 00:12:23,690
don't have a 360 controller, I won't be
asking any questions that would require

184
00:12:23,690 --> 00:12:28,700
you to have done sort of deep work with a
360 controller, but there's

185
00:12:28,700 --> 00:12:30,810
some general ideas about using a game

186
00:12:30,810 --> 00:12:34,100
pad particularly, versus a mouse that
would apply.

187
00:12:34,100 --> 00:12:37,280
For example, we don't have, our gamepad is
not

188
00:12:37,280 --> 00:12:39,180
a pointing device like the mouse, so we
don't

189
00:12:39,180 --> 00:12:43,500
get an x and a y for anything related to
the gamepad.

190
00:12:43,500 --> 00:12:45,960
So you should think about how we move
things around with

191
00:12:45,960 --> 00:12:50,465
the gamepad, versus moving things around
by making them follow the mouse.

192
00:12:50,465 --> 00:12:53,760
And of course, you know, there's lots of

193
00:12:53,760 --> 00:12:56,552
interesting things to do with gamepads as
well,

194
00:12:56,552 --> 00:13:01,150
but like I said as long as you get the
general ideas, you'll be in fine shape.

195
00:13:03,790 --> 00:13:08,540
And last but not least, we recently
covered how use the keyboard.

196
00:13:08,540 --> 00:13:10,680
How you can get input from the keyboard,

197
00:13:10,680 --> 00:13:12,950
by getting the current state of the
keyboard and

198
00:13:12,950 --> 00:13:16,250
some of the useful methods like Iskeydown,
that

199
00:13:16,250 --> 00:13:21,170
we can use, to actually process that
keyboard input.

200
00:13:21,170 --> 00:13:25,560
Now, this is an eight week course and we
just blasted through

201
00:13:25,560 --> 00:13:29,560
all the big idea,s in a fairly short
period of time here,

202
00:13:29,560 --> 00:13:34,150
but those are the core things that you
should take out of the course.

203
00:13:34,150 --> 00:13:37,000
And you'll have access to the archived
materials

204
00:13:37,000 --> 00:13:38,670
and everything for a long time to come.

205
00:13:38,670 --> 00:13:41,250
I'll talk about that in a different
lecture, but

206
00:13:42,830 --> 00:13:46,660
you should understand those things that
have been included.

207
00:13:46,660 --> 00:13:50,210
And if you do, if you've managed to say
you

208
00:13:50,210 --> 00:13:55,656
know, dor e for most of your answers to
these self-evaluation

209
00:13:55,656 --> 00:14:01,160
questions, then you probably will have no
significant trouble with the final exam.