1 00:00:10,058 --> 00:00:12,718 2 00:00:12,718 --> 00:00:15,988 This presentation is delivered by the Stanford Center for Professional 3 00:00:15,989 --> 00:00:22,989 Development. 4 00:00:24,210 --> 00:00:27,349 We have a little bit of unfinished business in this class, 5 00:00:27,349 --> 00:00:31,039 and the unfinished business is the graphics contest - well, besides our final review. 6 00:00:31,039 --> 00:00:34,010 And I've gotta say that the graphics contest - last time, I told you they 7 00:00:34,009 --> 00:00:36,170 were just impressive. I think 8 00:00:36,170 --> 00:00:40,450 they were more than just impressive. Some of them were just jaw dropping, 9 00:00:40,450 --> 00:00:44,090 so I'm gonna show you actually, and announce the winners of the 10 00:00:44,090 --> 00:00:47,460 graphics contest, as well as show you the winning entries. 11 00:00:47,460 --> 00:00:51,109 And we'll also do the random drawing to see of all the people who entered who 12 00:00:51,109 --> 00:00:54,729 gets the bonus prize. So our first winner, 13 00:00:54,729 --> 00:00:56,849 and if we have a little 14 00:00:56,850 --> 00:00:59,460 fanfare, I can kinda slide this to the side. Actually, 15 00:00:59,460 --> 00:01:03,179 I'll slide both these to the side. 16 00:01:03,179 --> 00:01:07,290 So we have two categories. We have algorithmic and aesthetic. 17 00:01:07,290 --> 00:01:10,530 In the algorithms category 18 00:01:10,530 --> 00:01:11,599 - 19 00:01:11,599 --> 00:01:14,089 algorithms, I can't even 20 00:01:14,090 --> 00:01:15,960 spell these days anymore. 21 00:01:15,959 --> 00:01:18,479 Is David Tobin here? 22 00:01:18,480 --> 00:01:25,430 David, come on down. So 23 00:01:25,430 --> 00:01:29,299 good job. As part of winning, there's a couple things you get. 24 00:01:29,299 --> 00:01:33,759 One is you get a bag of candy, a whole bag, well, not the whole thing. You get one of these. 25 00:01:33,759 --> 00:01:37,310 You can pick which one you want, though, so rummage through. A Milky Way 26 00:01:37,310 --> 00:01:39,790 fan? [Inaudible] Milky Way. All right, that's always good. 27 00:01:39,790 --> 00:01:43,590 And we'll show you - we'll demo your program and show what's actually going on, 28 00:01:43,590 --> 00:01:44,368 so 29 00:01:44,368 --> 00:01:47,900 the program that David did was a program to do fractals. 30 00:01:47,900 --> 00:01:51,940 And so I will show you that program, and what is particularly cool about the 31 00:01:51,939 --> 00:01:55,599 program. So if we do fractal graphics, it kinda starts off, and it shows you a 32 00:01:55,599 --> 00:01:56,489 fractal. 33 00:01:56,489 --> 00:01:59,599 And you're like oh, that's kinda cool. You need to do some math. You need to figure out some 34 00:01:59,599 --> 00:02:00,778 stuff with fractals. 35 00:02:00,778 --> 00:02:04,478 But as many of you know, fractals you can kind of zoom into at any range, 36 00:02:04,478 --> 00:02:06,929 so we can pick a range over here, 37 00:02:06,930 --> 00:02:10,729 and it will automatically zoom in and expand out, and we can just keep zooming into 38 00:02:10,729 --> 00:02:13,219 the fractal if we wanna keep going further. 39 00:02:13,218 --> 00:02:16,039 Now besides just that, that's kinda cool in itself, 40 00:02:16,039 --> 00:02:18,179 there's also some built-in fractals. 41 00:02:18,180 --> 00:02:21,640 So there's a few that David has lovingly provided for us that we can kind of look 42 00:02:21,639 --> 00:02:24,608 at, and that's kind of cool in itself. 43 00:02:24,609 --> 00:02:29,829 Now the thing that really made me go, "Wow, that is really cool," 44 00:02:29,829 --> 00:02:34,109 is not only are there these built-in fractals, there's a little text box down here. 45 00:02:34,109 --> 00:02:39,299 And in that text box, you can type in an equation for a fractal that 46 00:02:39,299 --> 00:02:43,730 includes exponents, and you type in the equation, it actually figures out - it 47 00:02:43,729 --> 00:02:48,429 parses your equation, runs the math on it, and then generates the fractal. 48 00:02:48,429 --> 00:02:51,899 And you can do this - it's sort of freeform. I was kinda playing 49 00:02:51,899 --> 00:02:55,459 with this other day, minus X raised to the fourth, 50 00:02:55,459 --> 00:02:59,200 so this X plus X squared minus X to the fourth down here, 51 00:02:59,199 --> 00:03:01,938 and it takes a little while because it's rendering every pixel on the 52 00:03:01,938 --> 00:03:02,718 screen 53 00:03:02,718 --> 00:03:08,258 how it should look. And so you can get these really cool effects, and then we can always zoom down. 54 00:03:08,258 --> 00:03:11,928 So it takes a little while to redraw, but it goes ahead and redraws it for you. So not only is it 55 00:03:11,929 --> 00:03:13,338 doing all the graphics, 56 00:03:13,338 --> 00:03:16,308 but it also is providing the opportunity for you to just type in an 57 00:03:16,308 --> 00:03:20,498 equation for it to understand the equation and render it, so very nice work. 58 00:03:20,498 --> 00:03:25,519 Thanks very much. And so as 59 00:03:25,519 --> 00:03:26,149 you know, 60 00:03:26,149 --> 00:03:29,959 for that effort, you also get 100 percent on anything in the class, which 61 00:03:29,959 --> 00:03:31,739 can include the final exam, 62 00:03:31,739 --> 00:03:35,069 which means at this point you can take your practice final and be like 63 00:03:35,069 --> 00:03:35,750 recycle bin 64 00:03:35,750 --> 00:03:39,509 if you choose to take the hundred on the final, which means you just don't 65 00:03:39,509 --> 00:03:43,659 show up, and when I see that little glaring gap I know oh yeah, that was 66 00:03:43,659 --> 00:03:46,728 100. That doesn't apply for everyone else, 67 00:03:46,729 --> 00:03:52,559 okay. Also, in the aesthetics category, 68 00:03:52,558 --> 00:03:56,019 69 00:03:56,019 --> 00:03:59,218 is Sally Hudson here? 70 00:03:59,218 --> 00:04:06,218 Come on down. It 71 00:04:08,628 --> 00:04:14,149 takes a little while. You also get your choice of the random candy. And you might wonder why 72 00:04:14,149 --> 00:04:15,620 there's random candy because 73 00:04:15,620 --> 00:04:19,728 well, I just buy a lot of candy at Safeway. Kit Kat fan? Good times. 74 00:04:19,728 --> 00:04:22,438 And what Sally did for her program - 75 00:04:22,439 --> 00:04:26,849 this is also pretty - well, a lot of the programs actually have very good algorithmic 76 00:04:26,848 --> 00:04:29,360 and aesthetic qualities, so it's hard to just pick one for the other, but it's a program 77 00:04:29,360 --> 00:04:31,000 called the Tessellator. 78 00:04:31,000 --> 00:04:34,579 And I'll show you what the Tessellator does. It starts with a little square. 79 00:04:34,579 --> 00:04:37,248 Anyone a fan of M. C. Escher? 80 00:04:37,249 --> 00:04:40,039 A tessellation is just where you put a bunch of little things on the screen, but 81 00:04:40,038 --> 00:04:43,659 they all have to fit together. So you can click on any part of this square, 82 00:04:43,660 --> 00:04:47,120 and to guarantee that it'll tessellate, the 83 00:04:47,120 --> 00:04:50,160 part of it that should allow for the tessellation to happen, basically sort of 84 00:04:50,160 --> 00:04:52,319 the corresponding piece on the other side, 85 00:04:52,319 --> 00:04:56,360 also kind of expands out. We don't want the tessellation to overwrite itself, so we 86 00:04:56,360 --> 00:04:59,900 can just kind of pick random areas, and that creates little places - or we can go 87 00:04:59,899 --> 00:05:02,739 this way 88 00:05:02,740 --> 00:05:05,879 - that create the tessellation. You might say, "That's kinda cool," but now we click set 89 00:05:05,879 --> 00:05:09,449 tile to set what the tile is. We've now defined what the tessellation tile is. We can change 90 00:05:09,449 --> 00:05:10,408 its size. 91 00:05:10,408 --> 00:05:14,430 So let's say I make it a little bit smaller because I like small tessellations, and that's kinda cool. But 92 00:05:14,430 --> 00:05:18,050 now I can pick multiple tiles of multiple colors, so let's say I want three 93 00:05:18,050 --> 00:05:19,819 different colors. 94 00:05:19,819 --> 00:05:23,809 Let's see. I have little my red, blue, green sliders over here, and notice the color 95 00:05:23,809 --> 00:05:25,220 changes as I slide, 96 00:05:25,220 --> 00:05:29,389 so I slide over here, so that's kind of a puce. I don't know. Well, 97 00:05:29,389 --> 00:05:34,038 we'll set the color. So it indicates your color over there. There's color No. 1. Let's just go - as 98 00:05:34,038 --> 00:05:37,500 the big Stanford Cardinal fans, we'll just go for red, although cardinal 99 00:05:37,500 --> 00:05:40,860 is slightly off from red, and I don't know where it's actually, so maybe it's got a little 100 00:05:40,860 --> 00:05:41,699 blue in it? 101 00:05:41,699 --> 00:05:43,020 Maybe a little green, too? 102 00:05:43,019 --> 00:05:45,508 Let's just say that's cardinal, although you would look at that and say, 103 00:05:45,509 --> 00:05:48,379 "But Mehran, that's really salmon." 104 00:05:48,379 --> 00:05:49,300 That's cool, too. 105 00:05:49,300 --> 00:05:51,669 And then we'll just pick another color where we'll 106 00:05:51,668 --> 00:05:55,248 go, "We won't go white." That's where you have all the - you could even just teach red, green, and 107 00:05:55,249 --> 00:05:58,289 blue with these three sliders by themselves. What happens if we put red 108 00:05:58,288 --> 00:05:59,498 and blue together? 109 00:05:59,499 --> 00:06:03,009 Oh, that's too close to the other one. Let's just go for some blue, so we set the color. 110 00:06:03,009 --> 00:06:05,269 Now at this point we go tessellate. 111 00:06:05,269 --> 00:06:08,668 And you'll notice because of the way the piece is drawn, you can tessellate everything 112 00:06:08,668 --> 00:06:10,798 together of the multiple colors. 113 00:06:10,798 --> 00:06:14,469 And you might think that's kind of cool, and that's kind of cool in itself, 114 00:06:14,470 --> 00:06:16,330 but it's kinda even cooler 115 00:06:16,329 --> 00:06:20,389 if the tessellating pieces decide to pop out and bounce around, 116 00:06:20,389 --> 00:06:23,590 multiple of them at the same time. 117 00:06:23,589 --> 00:06:24,368 118 00:06:24,369 --> 00:06:25,939 So very nice piece of work. 119 00:06:25,939 --> 00:06:32,620 Thank you very much. And 120 00:06:32,620 --> 00:06:35,620 this keeps going until they're all done, and you can actually just reset and do the 121 00:06:35,620 --> 00:06:37,079 whole thing all over again, 122 00:06:37,079 --> 00:06:39,158 and that's pretty cool. Now 123 00:06:39,158 --> 00:06:42,879 both of those programs are pretty cool, and you both get hundreds for your work. 124 00:06:42,879 --> 00:06:44,908 There was one program that was entered 125 00:06:44,908 --> 00:06:48,529 that when I showed it to the - well, first when I saw it, I went, 126 00:06:48,529 --> 00:06:50,788 "Oh my god," because it made you 127 00:06:50,788 --> 00:06:53,228 weep 128 00:06:53,228 --> 00:06:56,028 in a really good way. 129 00:06:56,028 --> 00:06:59,019 And then I showed it to the section leaders. Ben and I were demo'ing 130 00:06:59,019 --> 00:07:03,028 these because the section leaders all picked the winning entries, and they saw it. 131 00:07:03,028 --> 00:07:07,199 And as we went more and more into the different pieces, every time we 132 00:07:07,199 --> 00:07:09,149 showed a different piece, 133 00:07:09,149 --> 00:07:11,019 everyone just went, 134 00:07:11,019 --> 00:07:12,728 "Ah," 135 00:07:12,728 --> 00:07:15,968 and it was just unbelievable. So 136 00:07:15,968 --> 00:07:17,178 Chris Miel, 137 00:07:17,178 --> 00:07:19,438 are you here? Come on down. 138 00:07:19,439 --> 00:07:23,189 This is an additional award we're giving called the peoples' choice award because 139 00:07:23,189 --> 00:07:27,079 the entries were so good that we figured why stop at two. 140 00:07:27,079 --> 00:07:30,629 Because when it comes down to it, in this class there is some level of stuff that I 141 00:07:30,629 --> 00:07:33,759 want you to know, right? And if you demonstrate that you know that stuff, 142 00:07:33,759 --> 00:07:36,749 we can have some more awards. It's not a problem. So 143 00:07:36,749 --> 00:07:37,740 Chris, 144 00:07:37,740 --> 00:07:42,449 first of all you get to pick a bag of candy. 145 00:07:42,449 --> 00:07:45,199 And now I will show you Chris' 146 00:07:45,199 --> 00:07:46,929 program which is 147 00:07:46,928 --> 00:07:49,008 Zelda. 148 00:07:49,009 --> 00:07:53,139 All right? So it begins with this, and you're like, "Oh, that's very unassuming." 149 00:07:53,139 --> 00:07:56,389 So you start with the beginning graphics screen. If you look at this one thing, you 150 00:07:56,389 --> 00:07:59,168 kind of look at this for a while, and then you realize 151 00:07:59,168 --> 00:08:01,318 there's a little flash of light 152 00:08:01,319 --> 00:08:04,689 that goes across. Someone had to animate that, and they had to think about it. And 153 00:08:04,689 --> 00:08:08,509 so you can load a game, or you can start a new game, so I'll show you a new 154 00:08:08,509 --> 00:08:09,639 game. 155 00:08:09,639 --> 00:08:13,429 It has some nice graphics in there where again if you actually read everything 156 00:08:13,428 --> 00:08:16,288 - anyone in here Zelda fans? 157 00:08:16,288 --> 00:08:20,110 Yeah, I was when I was much younger. It's actually a very funny sort of 158 00:08:20,110 --> 00:08:27,110 take on the Zelda concept. Notice, if I turn different ways 159 00:08:28,699 --> 00:08:32,349 he's - 160 00:08:32,349 --> 00:08:35,090 oh, getting 161 00:08:35,090 --> 00:08:37,300 a little feedback there. 162 00:08:37,299 --> 00:08:40,459 There's a shield that I can use in different directions, and there are different 163 00:08:40,460 --> 00:08:44,070 screens I can go into, like I can go into this house over here, 164 00:08:44,070 --> 00:08:45,840 and here I can buy stuff. Like 165 00:08:45,840 --> 00:08:48,990 I've - I'm a little bit here so my hearts are down here, so I can say, 166 00:08:48,990 --> 00:08:50,769 "Hey. I wanna buy 167 00:08:50,769 --> 00:08:54,708 a couple more hearts," and I'll buy a potion, too. And here's 168 00:08:54,708 --> 00:08:59,219 my funds over here. Here's my magic potions and my emeralds that I buy stuff with. And 169 00:08:59,220 --> 00:09:01,399 I'll exit. 170 00:09:01,399 --> 00:09:04,769 And then I just kinda cruise along, 171 00:09:04,769 --> 00:09:07,899 and there's stuff that goes along in the world including things that like fade. 172 00:09:07,899 --> 00:09:10,250 Notice the fade effect there. And 173 00:09:10,250 --> 00:09:13,700 as you continue to cruise along in the world, you see various kinds of things that 174 00:09:13,700 --> 00:09:17,970 maybe we wanna kill, and just kind of cruise along. 175 00:09:17,970 --> 00:09:22,570 And you get to places where there's just animation going on everywhere, like the water's 176 00:09:22,570 --> 00:09:27,220 animated. I'm getting beat by the octopus. Never let yourself get beat by an octopus. And 177 00:09:27,220 --> 00:09:33,330 you can't do things like run into the river. It actually is aware of what - aw, I died. 178 00:09:33,330 --> 00:09:38,009 179 00:09:38,009 --> 00:09:45,009 That laugh 180 00:09:45,110 --> 00:09:46,480 goes on a little too long. There's a whole 181 00:09:46,480 --> 00:09:50,830 world you can explore. You can save the games and come back. I should 182 00:09:50,830 --> 00:09:55,629 be using my shield, but I'm kinda ignoramus with the shield. Oh, yeah. That's right, buddy. 183 00:09:55,629 --> 00:09:58,600 Sometimes when you kill something, it turns into an object. Sometimes it 184 00:09:58,600 --> 00:09:59,629 doesn't. And it was 185 00:09:59,629 --> 00:10:05,220 like every time you enter a different screen, it was like this. It was just 186 00:10:05,220 --> 00:10:07,330 187 00:10:07,330 --> 00:10:11,259 astounding. So - oh man, I haven't even seen this screen - [inaudible]. 188 00:10:11,259 --> 00:10:15,689 I know what I'm gonna be doing over winter break, so I will save you all the rest of the time. We'll just 189 00:10:15,690 --> 00:10:18,820 go in here, so you can see some stuff that's going on. 190 00:10:18,820 --> 00:10:20,230 Music changes. 191 00:10:20,230 --> 00:10:23,279 We probably can't actually show this on the video because I think are actually 192 00:10:23,279 --> 00:10:25,370 sampled from the real game, perhaps? Yeah, 193 00:10:25,370 --> 00:10:27,399 that's live from the city. 194 00:10:27,399 --> 00:10:34,399 But thank you. That's just an astounding piece of work. So 195 00:10:39,590 --> 00:10:41,180 sort of 196 00:10:41,179 --> 00:10:45,629 what I refer to as the peoples' choice award 197 00:10:45,629 --> 00:10:48,299 goes to Chris 198 00:10:48,299 --> 00:10:50,689 Miel. Am I pronouncing that right? Is that Miel? Yeah, it's Miel. 199 00:10:50,690 --> 00:10:51,790 Miel. All right. 200 00:10:51,789 --> 00:10:53,169 Good times. 201 00:10:53,169 --> 00:10:55,699 The other thing that came up is these, you get 100 percent 202 00:10:55,700 --> 00:10:58,350 on anything which is nontrivial, right? You're getting 100 percent on 203 00:10:58,350 --> 00:11:00,930 the final, and I looked at this, and I said, 204 00:11:00,929 --> 00:11:03,719 "I could give Chris 100 on the final, 205 00:11:03,720 --> 00:11:06,570 but I think he's pretty much demonstrated anything that I could 206 00:11:06,570 --> 00:11:11,540 possibly have wanted him to know in this class, so I'll just give him 207 00:11:11,539 --> 00:11:13,159 an A plus." So 208 00:11:13,159 --> 00:11:15,019 you're done. 209 00:11:15,019 --> 00:11:22,019 That's your grade. [Inaudible]. 210 00:11:24,679 --> 00:11:27,919 Thanks. And if any of the contest winners if at any point in your career you should need 211 00:11:27,919 --> 00:11:30,990 any recommendations, let me know. I'll be happy to write it. 212 00:11:30,990 --> 00:11:34,269 Now there were all sorts of honorable mentions. So these are all 213 00:11:34,269 --> 00:11:37,339 the winners of the contest. There were some honorable mentions, and I wanna 214 00:11:37,339 --> 00:11:40,140 recognize a couple of the honorable mentions that really stood out. 215 00:11:40,139 --> 00:11:42,078 Unfortunately, we don't have time to demo them all. There were a lot of 216 00:11:42,078 --> 00:11:45,039 cool programs, but a couple honorable mentions as well. 217 00:11:45,039 --> 00:11:46,419 Jasmine Mann? 218 00:11:46,419 --> 00:11:53,009 Yeah, you wanna come on down? 219 00:11:53,009 --> 00:11:57,569 And also Paris Georgegoudis? Am I pronouncing that right? 220 00:11:57,570 --> 00:11:59,240 Are you here? 221 00:11:59,240 --> 00:12:04,840 Oh, just too good to come to class, but we'll sort of give it to him anyway, Paris G. So 222 00:12:04,840 --> 00:12:08,950 Jasmine, you are also entitled to candy. Yay. 223 00:12:08,950 --> 00:12:10,999 And so one of the things you also get, 224 00:12:10,999 --> 00:12:14,209 as well as Paris who's not here, just for the 225 00:12:14,208 --> 00:12:17,429 very strong effort that you put in, is you know there's a participation grade in the 226 00:12:17,429 --> 00:12:18,179 class. 227 00:12:18,179 --> 00:12:20,989 So you automatically get 100 percent 228 00:12:20,990 --> 00:12:24,250 on your participation 229 00:12:24,250 --> 00:12:25,620 grade. 230 00:12:25,620 --> 00:12:30,029 So thanks very much for a nice piece of work. Jasmine did a musical piano that 231 00:12:30,029 --> 00:12:34,149 displayed some stars and had music, and Paris actually did a backgammon program 232 00:12:34,149 --> 00:12:38,779 with a computer player as well. So now 233 00:12:38,779 --> 00:12:40,069 there's finally a little 234 00:12:40,070 --> 00:12:43,190 more unfinished business to do which is that besides all the winners, there is 235 00:12:43,190 --> 00:12:47,220 also a random drawing for everyone who put a serious entry into the contest, and 236 00:12:47,220 --> 00:12:50,040 both Jasmine and Paris are both eligible for that 237 00:12:50,039 --> 00:12:53,490 potential 100 on the final. If you get the 100 on the final, though, you 238 00:12:53,490 --> 00:12:56,778 don't get the 100 on the participation because you only get one 239 00:12:56,778 --> 00:12:59,669 prize. It's your choice because if you happen to win, 240 00:12:59,669 --> 00:13:02,519 you get that 100 on whatever you want, so you can still use it for 241 00:13:02,519 --> 00:13:06,649 participation. But 242 00:13:06,649 --> 00:13:10,779 in terms of everyone else who's in the contest besides the 243 00:13:10,779 --> 00:13:14,459 winners, there was 14 total people who were in the contest. So I figured 244 00:13:14,460 --> 00:13:17,090 why don't we just pick the winner collectively 245 00:13:17,090 --> 00:13:18,660 in a random drawing, 246 00:13:18,659 --> 00:13:22,828 and so I wrote a little program, which just pales in comparison to Zelda. 247 00:13:22,828 --> 00:13:26,219 Actually, I even took this program from someone and modified it. 248 00:13:26,220 --> 00:13:28,670 That's how low budget this effort 249 00:13:28,669 --> 00:13:32,139 was because it was just a cool program. It was like, "Oh, that's cool. Let me just use that rather 250 00:13:32,139 --> 00:13:33,699 than rewriting it all myself." 251 00:13:33,700 --> 00:13:38,400 So what this does is it takes each of the entrants of the graphics contest 252 00:13:38,399 --> 00:13:42,019 and puts their name on a card. 253 00:13:42,019 --> 00:13:45,590 And those cards are shuffled and displayed on the screen. So what we're gonna do is pick 254 00:13:45,590 --> 00:13:47,028 one of those cards, 255 00:13:47,028 --> 00:13:50,588 and then this will gradually go through and reveal all the other cards who are 256 00:13:50,589 --> 00:13:56,220 the non-winners unfortunately. So you can sort of - I know it's kind of 257 00:13:56,220 --> 00:13:59,730 brutal, but that way you've got a sense if you're still kind of in the running as we go 258 00:13:59,730 --> 00:14:01,889 along. 259 00:14:01,889 --> 00:14:03,819 So 260 00:14:03,820 --> 00:14:07,300 now, I need to pick a card. These are all random, so it doesn't really matter which one I pick, 261 00:14:07,299 --> 00:14:11,009 although afterwards it'll be like why didn't you pick the one to the left. 262 00:14:11,009 --> 00:14:13,740 Oh, let's just pick this one. This one good? Yeah. [Inaudible]. 263 00:14:13,740 --> 00:14:17,120 Yeah. All right. See? 264 00:14:17,120 --> 00:14:22,080 Here's everyone else. They get revealed slowly. 265 00:14:22,080 --> 00:14:24,900 I don't know if you can hear the sound effect of the cards flipping 266 00:14:24,899 --> 00:14:27,610 over. Sorry, Jasmine. You don't win again, but 267 00:14:27,610 --> 00:14:30,750 you still got a prize up 268 00:14:30,750 --> 00:14:35,299 269 00:14:35,299 --> 00:14:36,599 here. 270 00:14:36,600 --> 00:14:39,310 Yeah, some of the cards once they're all covered up - well, Paris doesn't win 271 00:14:39,309 --> 00:14:40,779 again. 272 00:14:40,779 --> 00:14:43,379 And the winning entrant is - [inaudible] 273 00:14:43,379 --> 00:14:50,379 274 00:14:53,399 --> 00:14:57,850 actually did a very nice painting program. I don't remember all the entrants. 275 00:14:57,850 --> 00:15:01,190 And you have your choice of the Three Musketeers or 276 00:15:01,190 --> 00:15:03,780 277 00:15:03,779 --> 00:15:07,459 the [inaudible] bar. No one likes the Three 278 00:15:07,460 --> 00:15:09,990 Musketeers. I should write that down. 279 00:15:09,990 --> 00:15:11,350 I'll remember it. 280 00:15:11,350 --> 00:15:13,120 281 00:15:13,120 --> 00:15:13,879 Send me 282 00:15:13,879 --> 00:15:18,539 e-mail - also gets 100. Very nice work on the graphics contest. 283 00:15:18,539 --> 00:15:20,240 Thanks very much. 284 00:15:20,240 --> 00:15:23,850 And now with that bit of business taken care of, we can move on to 285 00:15:23,850 --> 00:15:28,560 reviewing for the final exam. So 286 00:15:28,559 --> 00:15:30,419 a little bit of final review, 287 00:15:30,419 --> 00:15:33,729 what you need to know, what you don't need to know, and maybe a couple examples 288 00:15:33,730 --> 00:15:34,300 of 289 00:15:34,299 --> 00:15:36,609 the level of difficulty we expect. 290 00:15:36,610 --> 00:15:40,409 So in terms of what's actually on the final, 291 00:15:40,409 --> 00:15:42,409 this is kinda what's on. 292 00:15:42,409 --> 00:15:45,309 And at a highest level, what's on the final 293 00:15:45,309 --> 00:15:46,279 is 294 00:15:46,279 --> 00:15:49,620 Chapters 2 through 13 of the book. Okay? 295 00:15:49,620 --> 00:15:54,778 So Karel is not on there, and Chapter 1 on history of Java not on there either. 296 00:15:54,778 --> 00:15:58,370 Now 2 through 13 covers a bunch of stuff, 297 00:15:58,370 --> 00:16:02,379 so in relation to that, let me start off by telling you what's not on the final 298 00:16:02,379 --> 00:16:06,519 so you get a sense of what are some of the things you don't have to spend your time 299 00:16:06,519 --> 00:16:10,490 on. Then I'll spend some time emphasizing some of the things you do 300 00:16:10,490 --> 00:16:12,200 wanna worry about studying. 301 00:16:12,200 --> 00:16:15,240 So history, 302 00:16:15,240 --> 00:16:20,080 the Chapter 1 stuff as I just mentioned, not on the final. 303 00:16:20,080 --> 00:16:23,530 Karel the robot not on the final. He's fun, but we're sorta done with Karel 304 00:16:23,529 --> 00:16:27,299 at this point. Zelda might be on the final. No, just kidding. 305 00:16:27,299 --> 00:16:30,538 Something people have been wondering about, stack heap diagrams 306 00:16:30,538 --> 00:16:32,169 not on the final. 307 00:16:32,169 --> 00:16:34,250 So stack heap, 308 00:16:34,250 --> 00:16:37,690 the diagrams are not on the final, but you might still be expected to know what is 309 00:16:37,690 --> 00:16:40,960 the difference between a stack and a heap, what gets allocated on the heap 310 00:16:40,960 --> 00:16:44,460 versus what gets allocated on the stack, but in terms of actually drawing the diagram 311 00:16:44,460 --> 00:16:48,480 with the memory addresses, that's not something that we'll ask you a question on. 312 00:16:48,480 --> 00:16:51,840 In terms of the chapter that has to do with images and graphics, there's a whole 313 00:16:51,840 --> 00:16:57,860 bunch of stuff if you read the whole chapter about bit operations on images. 314 00:16:57,860 --> 00:17:01,450 Bit operations not on the final, 315 00:17:01,450 --> 00:17:04,819 so if you sort of skipped that question, we didn't talk about it much in class 316 00:17:04,819 --> 00:17:07,519 except where we did a simple example where we took a 317 00:17:07,519 --> 00:17:10,519 picture that was color and turned it into black and white. Remember that? 318 00:17:10,519 --> 00:17:13,568 On Halloween, no less. I remember the lecture. 319 00:17:13,568 --> 00:17:16,990 Bit operations not on the final exam. You don't need to worry about that. 320 00:17:16,990 --> 00:17:19,319 Something we sort of stressed the whole time in the class which you didn't 321 00:17:19,319 --> 00:17:22,629 need to worry about was polar coordinates, 322 00:17:22,630 --> 00:17:25,440 so polar coordinates it's not like hey, we're gonna whip them out in the 323 00:17:25,440 --> 00:17:28,320 final exam, now you need to know them. You didn't to worry about them before. You don't need to worry 324 00:17:28,319 --> 00:17:29,579 about polar coordinates 325 00:17:29,579 --> 00:17:32,418 with respect to the graphics, right? And that's the only place they actually get 326 00:17:32,419 --> 00:17:34,650 used. Somewhere else in your life if you 327 00:17:34,650 --> 00:17:37,809 go exploring the poles or something, you might care about polar coordinates, but not 328 00:17:37,808 --> 00:17:39,839 in this class. 329 00:17:39,839 --> 00:17:43,059 So other things you don't need to worry about: 330 00:17:43,059 --> 00:17:44,500 layouts. 331 00:17:44,500 --> 00:17:48,140 We talked a bit about layouts when we talked about things like the border 332 00:17:48,140 --> 00:17:52,370 layout, and the table layout, and all this kind of stuff. And 333 00:17:52,369 --> 00:17:55,429 I showed you could lay things out where you have a program that has 334 00:17:55,430 --> 00:17:58,950 a text area for the console, and a canvas, and all that. 335 00:17:58,950 --> 00:18:01,779 You just don't need to worry about layouts at all. 336 00:18:01,779 --> 00:18:03,430 That's not something we'll ask 337 00:18:03,430 --> 00:18:05,700 about. Sorting - 338 00:18:05,700 --> 00:18:09,650 so Ben gave a nice lecture on sorting. Sorting's kinda useful. These days, sorting 339 00:18:09,650 --> 00:18:12,050 is mostly a solved problem. 340 00:18:12,049 --> 00:18:15,278 We're not gonna ask you any sorting questions on the 341 00:18:15,278 --> 00:18:18,190 final in the sense of you don't need to know any of the special sorting 342 00:18:18,190 --> 00:18:18,700 algorithms. 343 00:18:18,700 --> 00:18:22,610 We may ask you to keep something sorted, 344 00:18:22,609 --> 00:18:26,308 but if you think about keeping something sorted, that's different from 345 00:18:26,308 --> 00:18:28,089 sorting it from scratch. 346 00:18:28,089 --> 00:18:31,689 So we may or may not ask you to do this, but in terms of being able to sort 347 00:18:31,690 --> 00:18:35,049 something from scratch, like knowing selection sort or insertion sort, those 348 00:18:35,049 --> 00:18:37,809 algorithms you don't actually need to worry about them. 349 00:18:37,809 --> 00:18:42,039 The stuff we did on advanced topics where we talked about threads, 350 00:18:42,039 --> 00:18:44,849 you don't need to know. It was an advanced topic. It was for your own 351 00:18:44,849 --> 00:18:47,769 edification. Some of you used it in graphics projects, which was - or 352 00:18:47,769 --> 00:18:50,429 graphics contest entries, which was nice to see, but you don't need to know it. We're 353 00:18:50,429 --> 00:18:53,490 not gonna do any kind of testing on threads. Okay? 354 00:18:53,490 --> 00:18:57,599 And after threads, there was also a lecture on standard Java 355 00:18:57,599 --> 00:19:02,439 where we talked about the main method, and generating jar files, and 356 00:19:02,440 --> 00:19:04,650 all this nuts and bolts sort of stuff. 357 00:19:04,650 --> 00:19:06,040 That's not something we're gonna 358 00:19:06,039 --> 00:19:10,220 test you on either in the sense of standard - we'll still test you on Java. That 359 00:19:10,220 --> 00:19:12,019 doesn't mean you don't need to know any of Java, 360 00:19:12,019 --> 00:19:16,019 but just that specific stuff we talked about in relation to standard Java versus the 361 00:19:16,019 --> 00:19:16,839 ACM libraries, 362 00:19:16,839 --> 00:19:19,279 that's stuff you don't need to know about either. 363 00:19:19,279 --> 00:19:24,559 So what do you need to emphasize when you actually do your studying? 364 00:19:24,559 --> 00:19:26,009 Here are the topics, so 365 00:19:26,009 --> 00:19:29,950 if you pop all these topics out of Chapters 2 through 366 00:19:29,950 --> 00:19:30,279 13, 367 00:19:30,279 --> 00:19:32,980 the rest of the chapters are pretty much fair game, 368 00:19:32,980 --> 00:19:35,599 and here are some of the topics that generally come up which you wanna make 369 00:19:35,599 --> 00:19:37,339 sure you're good with. 370 00:19:37,339 --> 00:19:38,959 So the most basic thing 371 00:19:38,960 --> 00:19:42,490 is you need to be able to write programs, so you need to be able to build a 372 00:19:42,490 --> 00:19:43,779 program. 373 00:19:43,779 --> 00:19:49,329 That means knowing all the basic syntax that we talked about, what a 374 00:19:49,329 --> 00:19:52,389 class is, extending console program, if 375 00:19:52,390 --> 00:19:55,080 while loops, for loops, all that kind of stuff, 376 00:19:55,079 --> 00:19:56,788 you're just gonna need to know that. It's not 377 00:19:56,788 --> 00:20:01,269 like the exam will not have while loops in it, like do the exam without while loops. 378 00:20:01,269 --> 00:20:03,269 It's not gonna be like that. 379 00:20:03,269 --> 00:20:09,558 You should know also about objects, classes, and interfaces. 380 00:20:09,558 --> 00:20:13,769 What does it mean to implement an interface? What does it mean to define an 381 00:20:13,769 --> 00:20:17,589 object? What's a constructor for an object? What goes in a constructor for an 382 00:20:17,589 --> 00:20:19,000 object? 383 00:20:19,000 --> 00:20:19,859 Stuff like that. 384 00:20:19,859 --> 00:20:21,549 So you should be able to - 385 00:20:21,549 --> 00:20:26,389 if somewhere on the exam I asked you to define a class that does something, 386 00:20:26,390 --> 00:20:30,040 or perhaps define a class that implements a particular interface and show you what 387 00:20:30,039 --> 00:20:34,039 that interface is, you should be able to do that. Note on your sample - on your practice 388 00:20:34,039 --> 00:20:34,678 final, there 389 00:20:34,679 --> 00:20:38,130 actually is exactly a question of this form where you write a class 390 00:20:38,130 --> 00:20:39,440 that implements an interface 391 00:20:39,440 --> 00:20:42,429 so you get a sense for what that actually is. 392 00:20:42,429 --> 00:20:47,090 You should know about the mechanics of method calls. 393 00:20:47,089 --> 00:20:50,158 And part of the mechanics of method calls is what kind of things get passed 394 00:20:50,159 --> 00:20:53,899 by reference, meaning they get changed once you actually pass them, what kinds 395 00:20:53,898 --> 00:20:56,759 of things get passed by value, which means you get a copy and they don't 396 00:20:56,759 --> 00:20:58,109 change, 397 00:20:58,109 --> 00:20:59,579 and how those 398 00:20:59,579 --> 00:21:03,349 interact with what's actually going on when you make a method call. 399 00:21:03,349 --> 00:21:08,500 And so related to that is the notion of primitives versus 400 00:21:08,500 --> 00:21:10,529 objects. 401 00:21:10,529 --> 00:21:13,950 What are the primitive types? What does it mean for something to be an object? 402 00:21:13,950 --> 00:21:16,600 The general generic 403 00:21:16,599 --> 00:21:21,329 type object that all things that are objects are a subclass of the type object, so 404 00:21:21,329 --> 00:21:24,159 if you wanna write something that is entirely generic, you could write it in 405 00:21:24,160 --> 00:21:25,340 terms of 406 00:21:25,339 --> 00:21:29,689 being able to keep track of an object for example. And you did this to 407 00:21:29,690 --> 00:21:32,690 some extent when you did for example breakout. There instead of an object you 408 00:21:32,690 --> 00:21:34,789 had a GObject that you kept track of. 409 00:21:34,789 --> 00:21:37,670 What was the thing on the screen for example that you collided with? You wanted 410 00:21:37,670 --> 00:21:40,200 to see if that was a brick, or the paddle, or whatever? 411 00:21:40,200 --> 00:21:44,259 Hopefully, you did that for breakout but that's kind of the same idea there. 412 00:21:44,259 --> 00:21:45,920 So objects, classes, 413 00:21:45,920 --> 00:21:48,570 all that happy stuff - 414 00:21:48,569 --> 00:21:50,079 this is now in the 415 00:21:50,079 --> 00:21:53,720 what is in the final rather than not on the final, so I'll erase all the not on 416 00:21:53,720 --> 00:22:00,440 the final stuff. 417 00:22:00,440 --> 00:22:05,070 Other things that are also on the final, strings and characters. 418 00:22:05,069 --> 00:22:08,250 Know your strings and characters. Especially in relation to strings and 419 00:22:08,250 --> 00:22:11,609 characters, know your string operations. 420 00:22:11,609 --> 00:22:16,740 This is just a good thing either to have some tab say in your book to where the 421 00:22:16,740 --> 00:22:20,190 list of string operations is, or to have it on a separate piece of paper, 422 00:22:20,190 --> 00:22:24,179 or to print out for example lecture notes that are on the class website that contains a 423 00:22:24,179 --> 00:22:26,059 list of the standard string operations. 424 00:22:26,058 --> 00:22:29,440 It's just good to have them as a reference because you will invariably be doing at least one 425 00:22:29,440 --> 00:22:30,690 problem perhaps more 426 00:22:30,690 --> 00:22:33,649 that involves some kind of string operation manipulation, 427 00:22:33,648 --> 00:22:36,908 and unless you have them all memorized, if you have some handy reference, that's 428 00:22:36,909 --> 00:22:39,650 probably a good thing to have. 429 00:22:39,650 --> 00:22:43,740 And related to string operations is also - and dealing with 430 00:22:43,740 --> 00:22:46,160 characters, 431 00:22:46,160 --> 00:22:48,860 so the fact that you can pull individual characters out of a string, 432 00:22:48,859 --> 00:22:52,009 you can concatenate a series of characters together to build up a string which is a 433 00:22:52,009 --> 00:22:53,099 common way of actually 434 00:22:53,099 --> 00:22:56,809 building up a resulting string. That's also 435 00:22:56,809 --> 00:23:00,250 kind of related to that, so you need to know the interplay between characters and 436 00:23:00,250 --> 00:23:01,099 strings. 437 00:23:01,099 --> 00:23:03,359 Graphics, 438 00:23:03,359 --> 00:23:05,589 yeah, there's probably gonna be at least one 439 00:23:05,589 --> 00:23:09,019 question on there that involves graphics, and that's in terms of the ACM library, so 440 00:23:09,019 --> 00:23:14,079 all your happy friends like GRect, and GOval, and GCompound, and all 441 00:23:14,079 --> 00:23:15,210 that kind of stuff 442 00:23:15,210 --> 00:23:18,900 could potentially show up on the final exam. Again, this is probably 443 00:23:18,900 --> 00:23:22,429 somewhere in your book where you have all the different 444 00:23:22,429 --> 00:23:25,479 methods listed out for the ACM graphics library, it might be worth putting 445 00:23:25,479 --> 00:23:29,769 a little post-it or something in there so you can flip to it quickly if you need to. 446 00:23:29,769 --> 00:23:31,379 And related to graphics 447 00:23:31,380 --> 00:23:35,160 is event-driven programs, 448 00:23:35,160 --> 00:23:39,650 and by event-driven programs - we've looked at two kinds of event-driven programs. One is 449 00:23:39,650 --> 00:23:43,019 event-driven programs having to do with mouse inputs, so what we refer to as 450 00:23:43,019 --> 00:23:45,389 a mouse listener, 451 00:23:45,390 --> 00:23:49,570 like was the mouse moved, was the mouse clicked, all that happy stuff that you 452 00:23:49,569 --> 00:23:51,098 did for example in breakout. 453 00:23:51,098 --> 00:23:54,239 And then the stuff that you've been doing more recently with name surfer and also 454 00:23:54,239 --> 00:23:58,870 with face pamphlet which are action listeners 455 00:23:58,869 --> 00:24:02,479 which are various kinds of buttons, or text fields, or whatever the case may 456 00:24:02,480 --> 00:24:03,319 be. So 457 00:24:03,319 --> 00:24:06,329 you might have some program that actually for example 458 00:24:06,329 --> 00:24:10,259 uses both of these things that may take some mouse input or whatever and does 459 00:24:10,259 --> 00:24:14,899 some modification on graphics as a result. 460 00:24:14,898 --> 00:24:18,489 Uh huh? [Inaudible]. Ah, excellent. I was just about to say that, and you raised your hand first. No, you 461 00:24:18,490 --> 00:24:21,430 don't need to worry about key listeners. So 462 00:24:21,430 --> 00:24:24,480 anything we give you will be in terms of mouse listeners and action listeners. You 463 00:24:24,480 --> 00:24:28,220 don't need to worry about key listeners. 464 00:24:28,220 --> 00:24:29,880 So other kinds of stuff - 465 00:24:29,880 --> 00:24:33,640 then we got into the world of data structures, and we had arrays and array 466 00:24:33,640 --> 00:24:37,530 lists. 467 00:24:37,529 --> 00:24:39,879 These are also fair game 468 00:24:39,880 --> 00:24:43,390 for the final, so some things you should know is the differences for 469 00:24:43,390 --> 00:24:44,430 example 470 00:24:44,430 --> 00:24:45,019 between 471 00:24:45,019 --> 00:24:48,319 arrays and array lists. 472 00:24:48,319 --> 00:24:52,819 When is appropriate to use one of them versus the other, so the use of them, or 473 00:24:52,819 --> 00:24:53,470 use them. 474 00:24:53,470 --> 00:24:55,808 They're your friends. In the sense that if I give you a problem 475 00:24:55,808 --> 00:24:59,029 that involves - I give you kinda the setup for that problem, you should be 476 00:24:59,029 --> 00:25:03,149 able to choose is that appropriate for an array or an array list. I might tell you 477 00:25:03,150 --> 00:25:06,700 which one you should use, but if I don't, you should be able to 478 00:25:06,700 --> 00:25:08,319 determine what's appropriate. 479 00:25:08,319 --> 00:25:09,779 In terms of arrays, 480 00:25:09,779 --> 00:25:13,509 you also do need to worry about multidimensional arrays. 481 00:25:13,509 --> 00:25:18,059 You did some of this presumably already on the Yahtzee program, but 482 00:25:18,059 --> 00:25:21,319 multidimensional arrays - at least within reason. I won't give you anything like a 16-dimensional 483 00:25:21,319 --> 00:25:22,009 array, 484 00:25:22,009 --> 00:25:25,460 but probably two dimensions is fair game. Three is the upper limit. I wouldn't give 485 00:25:25,460 --> 00:25:27,548 you anything more than three dimensions. 486 00:25:27,548 --> 00:25:29,970 Likely if there's something with multidimensional arrays, it'll probably 487 00:25:29,970 --> 00:25:34,058 be two at most. Maybe it'll just be single dimension arrays. 488 00:25:34,058 --> 00:25:36,148 And also with array lists, 489 00:25:36,148 --> 00:25:39,000 everything that we've done in this class, which is also everything you need to 490 00:25:39,000 --> 00:25:44,539 worry about for the final, is sort of the Java 5.0 491 00:25:44,539 --> 00:25:49,119 or later version of array lists. So in the book there's always sort of two 492 00:25:49,119 --> 00:25:52,439 versions. There's the here's how you use array lists before Java 5.0 493 00:25:52,440 --> 00:25:55,088 and here's how you use array lists after Java 5.0, 494 00:25:55,088 --> 00:25:56,230 or 5.0 and later. 495 00:25:56,230 --> 00:25:59,789 You don't need to worry about the before 5.0 stuff. Just the 5.0 and later is 496 00:25:59,789 --> 00:26:02,829 all you're gonna need because that's all we've emphasized in the class, and 497 00:26:02,829 --> 00:26:03,529 that's 498 00:26:03,529 --> 00:26:06,960 these days what everyone's using anyway. 499 00:26:06,960 --> 00:26:11,269 And then after arrays and array lists, which was kind of the 500 00:26:11,269 --> 00:26:13,980 introduction to the whole notion of Java collections, 501 00:26:13,980 --> 00:26:15,990 was thinking about 502 00:26:15,990 --> 00:26:16,910 collections. 503 00:26:16,910 --> 00:26:18,460 So besides 504 00:26:18,460 --> 00:26:20,960 just array lists you also saw hashmap, 505 00:26:20,960 --> 00:26:25,700 which hopefully at this point you are just the master of the hashmap, 506 00:26:25,700 --> 00:26:29,319 but you should know the hashmap. And things that come along with hashmaps 507 00:26:29,319 --> 00:26:32,259 and collections in general, or the collection interface - 508 00:26:32,259 --> 00:26:35,509 I should say collection instead of collections - 509 00:26:35,509 --> 00:26:38,119 is for example an iterator. 510 00:26:38,119 --> 00:26:41,899 What is an iterator? How do you get an iterator from a collection? How do you use an 511 00:26:41,900 --> 00:26:42,440 iterator? 512 00:26:42,440 --> 00:26:45,129 That's something that you just wanna be facile with because 513 00:26:45,128 --> 00:26:46,199 chances are for some problem 514 00:26:46,200 --> 00:26:49,590 to solve the problem, especially if you're doing something that involved a hashmap, 515 00:26:49,589 --> 00:26:49,978 516 00:26:49,979 --> 00:26:52,710 you probably wanna be able to get an iterator. And then hashmap you've gotta know, 517 00:26:52,710 --> 00:26:56,190 "Oh, hashmap, I need to get the set of keys." Right? The keyset to be able to get 518 00:26:56,190 --> 00:26:57,529 the iterator on that. 519 00:26:57,529 --> 00:27:02,139 So these are also good places to have tabs in your book for quick 520 00:27:02,140 --> 00:27:03,970 reference if you need them. 521 00:27:03,970 --> 00:27:07,230 And last but not least, files. 522 00:27:07,230 --> 00:27:09,079 So the basics of files. 523 00:27:09,079 --> 00:27:12,539 And you've done a lot of the basics of files already. Know how to open a file 524 00:27:12,539 --> 00:27:13,819 and read from a file. 525 00:27:13,819 --> 00:27:17,009 Know how to be able to write to a file if you need to write to a file. Chances are we probably 526 00:27:17,009 --> 00:27:20,450 won't have you write to a file since you didn't have to do it on any of the assignments, 527 00:27:20,450 --> 00:27:21,548 but at least 528 00:27:21,548 --> 00:27:22,259 reading 529 00:27:22,259 --> 00:27:25,980 from a file is fair game. 530 00:27:25,980 --> 00:27:30,759 So topically, that's kinda what's going on there. Now 531 00:27:30,759 --> 00:27:31,359 given 532 00:27:31,359 --> 00:27:35,308 the topics, let me show you some examples of the kind of questions we 533 00:27:35,308 --> 00:27:38,158 might ask besides what's on the practice final which you already have sort 534 00:27:38,159 --> 00:27:39,239 of a whole 535 00:27:39,239 --> 00:27:40,600 practice final that you can do, 536 00:27:40,599 --> 00:27:43,408 and I would encourage you to do that under a timed condition, so you can figure 537 00:27:43,409 --> 00:27:46,889 out what kind of things you're maybe a little rusty on, and what kinds of things 538 00:27:46,888 --> 00:27:49,149 you're feeling good about. 539 00:27:49,150 --> 00:27:51,400 Here's an example of the kind of question we might 540 00:27:51,400 --> 00:27:53,440 give that involves a bunch of these concepts, 541 00:27:53,440 --> 00:27:54,570 which is 542 00:27:54,569 --> 00:27:55,889 given a hashmap - 543 00:27:55,890 --> 00:28:00,450 so you're given some hashmap whose type is hashmap string 544 00:28:00,450 --> 00:28:01,990 to 545 00:28:01,990 --> 00:28:04,940 string, and you know that these are keys and values. 546 00:28:04,940 --> 00:28:05,840 Find 547 00:28:05,839 --> 00:28:07,058 essentially all 548 00:28:07,058 --> 00:28:09,039 key values are the same. 549 00:28:09,039 --> 00:28:12,710 So what we want you to do is find 550 00:28:12,710 --> 00:28:14,650 matching 551 00:28:14,650 --> 00:28:17,670 key value pairs. What do I mean by that? 552 00:28:17,670 --> 00:28:20,890 What I mean is let's say we have some hashmap where here are the keys over here, and here are 553 00:28:20,890 --> 00:28:22,390 the values over here. 554 00:28:22,390 --> 00:28:27,049 And I might have some keys like Alice, and Bob, 555 00:28:27,048 --> 00:28:28,558 and Cathy. 556 00:28:28,558 --> 00:28:33,799 And I might have some values like Alice, Jeff, 557 00:28:33,799 --> 00:28:35,879 and Cathy. 558 00:28:35,880 --> 00:28:39,420 And so what I wanna find out for example to print on the screen is I'd 559 00:28:39,420 --> 00:28:41,820 wanna print Alice, and I'd wanna print Cathy. 560 00:28:41,819 --> 00:28:46,669 I wanna write out any of the keys whose value is basically as 561 00:28:46,670 --> 00:28:49,070 their value in the hashmap. 562 00:28:49,069 --> 00:28:51,269 So that's a very simple sort of set up, 563 00:28:51,269 --> 00:28:54,159 but it stresses a bunch of these concepts that you need to know to be 564 00:28:54,159 --> 00:28:55,350 able to do it. 565 00:28:55,349 --> 00:28:58,279 And that's kind of hopefully the way a lot of the questions are gonna be on the 566 00:28:58,279 --> 00:28:58,798 final 567 00:28:58,798 --> 00:29:01,490 is simple concepts but stresses the ideas. 568 00:29:01,490 --> 00:29:04,160 So if we wanna think about solving that problem, 569 00:29:04,160 --> 00:29:05,259 570 00:29:05,259 --> 00:29:07,150 we might be given some 571 00:29:07,150 --> 00:29:09,679 header like public 572 00:29:09,679 --> 00:29:11,810 void 573 00:29:11,809 --> 00:29:14,069 match keys, 574 00:29:14,069 --> 00:29:17,849 and this has some parameter that it's passed like a hashmap 575 00:29:17,849 --> 00:29:19,849 from string to string that 576 00:29:19,849 --> 00:29:22,579 we'll 577 00:29:22,579 --> 00:29:24,199 call map. 578 00:29:24,200 --> 00:29:27,670 And all this syntax should hopefully be stuff that's just second nature to you 579 00:29:27,670 --> 00:29:30,320 at this point. You really wanna figure out how to solve the problem. If you 580 00:29:30,319 --> 00:29:32,579 think about this problem, if we wanna find out 581 00:29:32,579 --> 00:29:36,439 which keys have the same value as their value, what's the 582 00:29:36,440 --> 00:29:40,039 first thing we wanna do? 583 00:29:40,039 --> 00:29:43,019 Run iterate over the keys, right? We wanna have some way of saying, "Okay, I 584 00:29:43,019 --> 00:29:46,029 need to go through all the keys and look at them to see if they have the same 585 00:29:46,029 --> 00:29:48,058 value as their value." So 586 00:29:48,058 --> 00:29:50,539 I'd need to have some iterator. The 587 00:29:50,539 --> 00:29:54,129 iterator I know would have to be over strings because it's gonna be an iterator over the 588 00:29:54,130 --> 00:29:58,720 type of whatever the key is for the hashmap, and I'll call it it. And how do I get an 589 00:29:58,720 --> 00:30:00,649 iterator from the hashmap or 590 00:30:00,648 --> 00:30:04,369 over the keyset of the hashmap? 591 00:30:04,369 --> 00:30:06,579 So I need to say map dot keyset - 592 00:30:06,579 --> 00:30:07,808 these 593 00:30:07,808 --> 00:30:11,990 are good things to know in the back of your head - iterator - we sort of 594 00:30:11,990 --> 00:30:15,230 string these all together, and so what I now get is an 595 00:30:15,230 --> 00:30:18,329 iterator of strings which are all my keys in the hashmap. 596 00:30:18,329 --> 00:30:19,769 And now at this point 597 00:30:19,769 --> 00:30:23,319 it's just using my iterator but in conjunction with some other functions, 598 00:30:23,319 --> 00:30:26,538 like while my iterator has a next - 599 00:30:26,538 --> 00:30:30,819 and if you wanna use sort of the funky for each notation that's also in 600 00:30:30,819 --> 00:30:34,329 the book where it allows you to do iteration over an iterator 601 00:30:34,329 --> 00:30:37,189 in kind of a stylized form, that's fine, too, but we 602 00:30:37,190 --> 00:30:41,120 didn't stress that in class, so I'm not gonna stress it here. 603 00:30:41,119 --> 00:30:46,569 While the iterator has a next element, I just get that 604 00:30:46,569 --> 00:30:50,259 next element - equals it dot next. 605 00:30:50,259 --> 00:30:53,640 And then I wanna see is this key equal to the value. 606 00:30:53,640 --> 00:30:56,778 So now it's gonna stress another hashmap concept which is to go look something 607 00:30:56,778 --> 00:30:57,869 up in the hashmap, 608 00:30:57,869 --> 00:31:02,349 and so I have string value equals 609 00:31:02,349 --> 00:31:04,719 map dot get, 610 00:31:04,720 --> 00:31:09,659 and what I'm gonna get from the map is whatever matches that key. So if my 611 00:31:09,659 --> 00:31:12,970 key happened to be Alice over here, I'd go and get the value which is Alice out 612 00:31:12,970 --> 00:31:15,480 of 613 00:31:15,480 --> 00:31:22,038 the hashmap, and I'll just keep writing the rest of it over here. We're almost done. So 614 00:31:22,038 --> 00:31:24,400 over here we just say if 615 00:31:24,400 --> 00:31:27,860 the particular value that I got happens to match the key. Now it's gonna 616 00:31:27,859 --> 00:31:29,569 stress the concept of strings. 617 00:31:29,569 --> 00:31:31,839 So all these kinds of things fit together. 618 00:31:31,839 --> 00:31:33,778 If value dot 619 00:31:33,778 --> 00:31:36,630 equals 620 00:31:36,630 --> 00:31:39,528 key, which means that value equals the key value, 621 00:31:39,528 --> 00:31:41,960 then I print out to the screen to the 622 00:31:41,960 --> 00:31:45,309 key. I could print out the value, too, because they're both the same at this point, 623 00:31:45,309 --> 00:31:50,079 but that's the whole deal. That's the end of my while loop. That's the end of my method. 624 00:31:50,079 --> 00:31:53,619 So that's kinda the idea, right? This was not particularly earth shattering, 625 00:31:53,619 --> 00:31:56,928 but it stresses a bunch of concepts. Unless you remember the little things 626 00:31:56,929 --> 00:32:00,570 like, "Oh yeah, I need to get the iterator over the keyset," which is kind of a very 627 00:32:00,569 --> 00:32:02,118 standard pattern with hashmaps, 628 00:32:02,118 --> 00:32:05,038 it could take you a lot longer than it otherwise needs to take you. Okay, 629 00:32:05,038 --> 00:32:08,400 so any questions about that? 630 00:32:08,400 --> 00:32:10,710 Let me show you one other simple example 631 00:32:10,710 --> 00:32:13,069 that's the sort of thing that would be fair game 632 00:32:13,069 --> 00:32:15,808 which is a little program called target seeker. 633 00:32:15,808 --> 00:32:19,579 Basically the idea here is there's a little target that's a red square, and 634 00:32:19,579 --> 00:32:22,939 there's a little target seeker that comes after it which is the black square. And the 635 00:32:22,940 --> 00:32:26,320 black square's trying to get its center to match up directly with the center of the 636 00:32:26,319 --> 00:32:27,230 red square, 637 00:32:27,230 --> 00:32:30,240 fairly straightforward. And every time I click the mouse, 638 00:32:30,240 --> 00:32:34,650 I move the target somewhere else, so I'm just keeping the seeker - it's like, "Oh look, 639 00:32:34,650 --> 00:32:36,730 I'm so confused." 640 00:32:36,730 --> 00:32:39,700 Every time I click the mouse, the center of the target moves to the 641 00:32:39,700 --> 00:32:43,980 current mouse location, and the seeker just keeps seeking to wherever that 642 00:32:43,980 --> 00:32:45,259 target is. 643 00:32:45,259 --> 00:32:48,470 This problem won't be on the final, 1.) because I'm showing it to you now, and 2.) because 644 00:32:48,470 --> 00:32:50,879 it's really difficult to actually put that in a handout. Like 645 00:32:50,878 --> 00:32:56,038 take these set of pages and just flip through them really quickly and you can see what the seeker is doing. So 646 00:32:56,038 --> 00:32:57,789 how do you turn this into code? 647 00:32:57,789 --> 00:33:00,940 And the code for this is actually fairly straightforward. It's kind of you need 648 00:33:00,940 --> 00:33:04,350 to think about what you were doing in breakout, right? So some of the problems that you're gonna 649 00:33:04,349 --> 00:33:05,618 solve 650 00:33:05,618 --> 00:33:08,298 leverage concepts that you've seen in your programs, so you've had experience with 651 00:33:08,298 --> 00:33:10,000 these kinds of things before. 652 00:33:10,000 --> 00:33:12,180 What we do is we initialize the target. 653 00:33:12,180 --> 00:33:13,400 Let 654 00:33:13,400 --> 00:33:16,090 me just line up these lines so it looks a little nicer. 655 00:33:16,089 --> 00:33:20,288 The target is basically just a rectangle whose size is some constant target size 656 00:33:20,288 --> 00:33:23,849 that's defined down here. I'll just show it to you. Target size happens to be ten, 657 00:33:23,849 --> 00:33:28,439 seeker size is twenty, and there's a pause time of ten, just so you know. So 658 00:33:28,440 --> 00:33:31,980 target square is gonna be the target. Target square is gonna be some new 659 00:33:31,980 --> 00:33:34,098 GRect that we set up, and that's a local - 660 00:33:34,098 --> 00:33:38,198 or a private instance variable that I wanna keep track of. My target square is just a 661 00:33:38,199 --> 00:33:39,750 private GRect. 662 00:33:39,750 --> 00:33:43,419 My seeker is also gonna be a private GRect, and I'm gonna keep track of the target that 663 00:33:43,419 --> 00:33:47,820 I wanna get to in a private X and Y location known as target X and Y. 664 00:33:47,819 --> 00:33:49,019 So when I start off, 665 00:33:49,019 --> 00:33:52,298 I just set my target to be a square of this size, 666 00:33:52,298 --> 00:33:53,710 its color is red, 667 00:33:53,710 --> 00:33:56,900 and it's filled to be true, so it just initializes the target. 668 00:33:56,900 --> 00:33:59,809 And now I say, "Hey, the target starts in the middle of the screen." Presumably that 669 00:33:59,808 --> 00:34:02,450 would be in the instructions for the assignment, and so I get the middle of 670 00:34:02,450 --> 00:34:05,558 the screen. Know your standard ways of computing the centers of 671 00:34:05,558 --> 00:34:07,629 something. That's always good to know. 672 00:34:07,630 --> 00:34:09,329 Then I add my target 673 00:34:09,329 --> 00:34:11,858 to essentially the center of the screen, which means if 674 00:34:11,858 --> 00:34:15,858 I remember that my target square, the place I add it to a canvas is actually its 675 00:34:15,858 --> 00:34:19,219 upper left hand corner, I need to take the target X which is the middle of the 676 00:34:19,219 --> 00:34:19,749 screen, 677 00:34:19,748 --> 00:34:23,308 and subtract off half the width of the target in both the X direction and the 678 00:34:23,309 --> 00:34:26,619 Y direction to get its upper left hand corner. 679 00:34:26,619 --> 00:34:29,429 And then I add it to the screen, so this just sets up the target. 680 00:34:29,429 --> 00:34:33,849 Then I set up the seeker, and the seeker is also a square of size seeker size by seeker 681 00:34:33,849 --> 00:34:34,309 size, 682 00:34:34,309 --> 00:34:37,309 and it just starts at zero, zero. That's presumably something that would 683 00:34:37,309 --> 00:34:41,219 be given to you in the problem, that the seeker just starts at a different location. 684 00:34:41,219 --> 00:34:42,980 And once I've set up the 685 00:34:42,980 --> 00:34:46,170 target and the seeker, I add my mouse listeners because I need to know where my 686 00:34:46,170 --> 00:34:49,960 mouse clicks, and then I just have this loop that's just always seeking. 687 00:34:49,960 --> 00:34:54,079 It's just always trying to find wherever the target is. And 688 00:34:54,079 --> 00:34:58,489 the target starts off at this target X Y location. That's where it always - how we're 689 00:34:58,489 --> 00:35:01,228 always gonna keep track of it. So what happens is 690 00:35:01,228 --> 00:35:03,348 on every step of seek 691 00:35:03,349 --> 00:35:06,609 we pause just so the seeker doesn't just jump there. It's not very exciting if the 692 00:35:06,608 --> 00:35:08,150 seeker just jumps there every time. 693 00:35:08,150 --> 00:35:12,318 And we say is the midpoint of the seeker - let's get that. That's just the seeker's 694 00:35:12,318 --> 00:35:14,599 current X location, which is upper left 695 00:35:14,599 --> 00:35:17,569 plus half the size of the seeker to come in. 696 00:35:17,570 --> 00:35:20,480 And we would do the same thing on the Y, which means we would go down half the 697 00:35:20,480 --> 00:35:25,099 size of the seeker in the Y direction. If my target X is greater than my 698 00:35:25,099 --> 00:35:26,139 current X, 699 00:35:26,139 --> 00:35:29,799 then I need to move positively in the X direction. Otherwise, I wanna move 700 00:35:29,800 --> 00:35:31,359 negatively in the X direction. 701 00:35:31,358 --> 00:35:36,288 And similarly with the Y coordinate, right? If my Y - so I find the seeker's midpoint 702 00:35:36,289 --> 00:35:38,960 Y. If my Y is less than the target Y, 703 00:35:38,960 --> 00:35:42,570 I need to move toward the target Y, so I'm gonna increase Y. 704 00:35:42,570 --> 00:35:46,449 If my target Y's less than the seeker's Y, I'm gonna decrease Y. 705 00:35:46,449 --> 00:35:49,679 So I just find these offsets. Are you gonna move in the positive or negative X 706 00:35:49,679 --> 00:35:52,099 direction, or are you gonna move in the positive or negative Y direction? 707 00:35:52,099 --> 00:35:59,099 And then I'm gonna have the seeker move one step in that direction. Uh huh? Why'd you do that instead of just finding the location [inaudible]? 708 00:36:02,528 --> 00:36:08,900 Having it move consistently with - [Inaudible]. 709 00:36:08,900 --> 00:36:12,130 Well, so if you actually wanna do that, if you wanna have it look more nicely 710 00:36:12,130 --> 00:36:15,048 so that rather than trying to match up the Xs and then the Ys, if you wanna 711 00:36:15,048 --> 00:36:17,288 move toward it, you need to compute angles, 712 00:36:17,289 --> 00:36:19,640 and I just didn't wanna deal with polar coordinates, 713 00:36:19,639 --> 00:36:22,690 but you actually can do it with polar coordinates. We just don't do it because 714 00:36:22,690 --> 00:36:24,719 we're not - that's another thing that you know. 715 00:36:24,719 --> 00:36:27,400 You don't need polar coordinates, which is why you don't need to know that. 716 00:36:27,400 --> 00:36:30,989 And the only time the target gets updated is when the mouse gets clicked. We set 717 00:36:30,989 --> 00:36:34,798 the target X and the target Y to be the new location of where we clicked. 718 00:36:34,798 --> 00:36:38,788 We removed the old target from wherever its location was, and we add it back to 719 00:36:38,789 --> 00:36:40,619 the new location. 720 00:36:40,619 --> 00:36:43,969 And that's the whole program. That's kinda the level of difficulty. Now this is a program 721 00:36:43,969 --> 00:36:47,179 that when you have the code, I can explain it all in like five minutes or so, 722 00:36:47,179 --> 00:36:49,749 but when you're writing this from scratch, I would probably expect that writing 723 00:36:49,748 --> 00:36:52,539 this program would take probably on the order of about 724 00:36:52,539 --> 00:36:55,048 20 to 30 minutes to write it from scratch 725 00:36:55,048 --> 00:36:57,958 with some false starts, et cetera, et cetera. But this is kind of the level of 726 00:36:57,958 --> 00:37:01,628 difficulty you could expect to see on the final exam, and a notion of 727 00:37:01,628 --> 00:37:04,068 about how much time we would actually give you for it. 728 00:37:04,068 --> 00:37:07,940 So any questions about this or about our little hashmap example? That kind 729 00:37:07,940 --> 00:37:09,400 of gives you a sense of 730 00:37:09,400 --> 00:37:13,400 a set of topics or the richness in some of the questions. 731 00:37:13,400 --> 00:37:16,530 And you sort of got the explicit list of topics as well for the 732 00:37:16,530 --> 00:37:18,639 class. So 733 00:37:18,639 --> 00:37:21,798 any questions about the final? You're feeling 734 00:37:21,798 --> 00:37:24,659 okay. So I wanted to give you a bit of wrap up if there's no more questions, given 735 00:37:24,659 --> 00:37:26,939 that this is our last class. 736 00:37:26,938 --> 00:37:27,690 So if you kind of 737 00:37:27,690 --> 00:37:33,119 think about where we've been, 738 00:37:33,119 --> 00:37:35,369 we sort of had ten weeks - a 739 00:37:35,369 --> 00:37:38,349 little less than ten weeks if you count 740 00:37:38,349 --> 00:37:42,999 some - oh, we had a day off after the midterm, and we had a day off on Friday, 741 00:37:42,998 --> 00:37:45,118 and whatever the case may be. 742 00:37:45,119 --> 00:37:48,099 But I would imagine for a lot of people in this class, 743 00:37:48,099 --> 00:37:51,289 there wasn't necessarily - there was some previous programming experience because I went 744 00:37:51,289 --> 00:37:54,028 through all your Assignment No. 1 e-mails. Remember those? That was 745 00:37:54,028 --> 00:37:55,079 so long ago. 746 00:37:55,079 --> 00:37:59,078 There was some prior programming experience, but there wasn't a lot of programming 747 00:37:59,079 --> 00:38:03,059 experience. So the real hope in this class was to get you to a point where 748 00:38:03,059 --> 00:38:06,319 basically you could take this journey over here from not necessarily doing any 749 00:38:06,318 --> 00:38:08,798 programming to getting to a point over here 750 00:38:08,798 --> 00:38:12,199 where now a bunch of the stuff that you actually see, like games that you 751 00:38:12,199 --> 00:38:14,398 actually 752 00:38:14,398 --> 00:38:17,170 play either online or in an arcade if 753 00:38:17,170 --> 00:38:21,250 any arcades even exist anymore, like on your Xbox or whatever, say like 754 00:38:21,250 --> 00:38:22,650 Zelda. 755 00:38:22,650 --> 00:38:25,999 For other kinds of things that you interact with like a data management 756 00:38:25,998 --> 00:38:28,149 system or social network, 757 00:38:28,150 --> 00:38:31,639 when it comes down to it, hopefully this class has helped demystify some of those 758 00:38:31,639 --> 00:38:33,929 things, that really underneath the hood, 759 00:38:33,929 --> 00:38:37,088 yeah, there's a bunch of listeners that are looking for things, and there are some 760 00:38:37,088 --> 00:38:40,699 graphics that get updated, and there's little pause loops, and we need to look for mouse 761 00:38:40,699 --> 00:38:42,200 events, and keyboard events. 762 00:38:42,199 --> 00:38:45,588 There's a bunch of big data structures like arrays, and hashmaps, and 763 00:38:45,588 --> 00:38:48,019 stuff like that. They keep track of stuff like 764 00:38:48,019 --> 00:38:52,038 your list of friends in the social network, or the communities you belong in. 765 00:38:52,039 --> 00:38:54,599 When you use a search engine, 766 00:38:54,599 --> 00:38:56,289 this is just doing the same thing. 767 00:38:56,289 --> 00:38:59,969 There's just some really huge repository of data that you now need 768 00:38:59,969 --> 00:39:02,968 to go look up. And the interesting problems that come up are things like 769 00:39:02,969 --> 00:39:07,369 this huge repository of data doesn't fit on one computer anymore. So what do you 770 00:39:07,369 --> 00:39:10,739 do? You break it up onto a bunch of smaller computers, and each of them gets 771 00:39:10,739 --> 00:39:14,079 some chunk of the data. And now you go from just simple data management problem 772 00:39:14,079 --> 00:39:17,000 to something worrying about breaking up data into bigger pieces. 773 00:39:17,000 --> 00:39:19,759 And this is how computer science progresses 774 00:39:19,759 --> 00:39:23,148 in the sense that the problems get bigger in terms of what we actually deal 775 00:39:23,148 --> 00:39:23,670 with, 776 00:39:23,670 --> 00:39:26,929 and the interactions with the user get more complicated. 777 00:39:26,929 --> 00:39:30,800 But hopefully along the way what you learned in this journey was the science 778 00:39:30,800 --> 00:39:34,689 of what's involved in doing this stuff. So it's just a bunch of science as to 779 00:39:34,688 --> 00:39:38,188 how you actually figure out how all these pieces of a game interact, or how 780 00:39:38,188 --> 00:39:41,908 data is kept track of in some larger system, especially when you have smaller 781 00:39:41,909 --> 00:39:44,909 components that need to be kept track of in arrays and hashmaps that build up into 782 00:39:44,909 --> 00:39:46,349 larger components. 783 00:39:46,349 --> 00:39:48,588 And so those are the scientific parts of it. 784 00:39:48,588 --> 00:39:52,369 But hopefully as you also saw today when we showed some of the graphics contest 785 00:39:52,369 --> 00:39:55,068 examples and when you wrote your programs there was obviously a variety of ways of 786 00:39:55,068 --> 00:39:56,358 doing the programs. That 787 00:39:56,358 --> 00:39:59,690 was the thing that at the beginning of the class isn't always clear 788 00:39:59,690 --> 00:40:02,208 is there's a huge art in computer science, 789 00:40:02,208 --> 00:40:05,338 which is why the textbook for the class is called the Art and Science of 790 00:40:05,338 --> 00:40:06,909 Computer Science - is 791 00:40:06,909 --> 00:40:10,149 this class, we taught you a lot of this stuff, and we hopefully taught you along 792 00:40:10,150 --> 00:40:13,930 the way some of the skills to be a good artist and to be a good software 793 00:40:13,929 --> 00:40:15,199 engineer. 794 00:40:15,199 --> 00:40:18,649 And the real key in programming is you'll learn more of this stuff as you go along, 795 00:40:18,650 --> 00:40:21,710 as you become a computer scientist because there is computer science after 796 00:40:21,710 --> 00:40:22,139 all 797 00:40:22,139 --> 00:40:25,009 in computer science, and so you'll learn more of this stuff. 798 00:40:25,009 --> 00:40:27,699 But what you'll also develop as you go along the way 799 00:40:27,699 --> 00:40:29,298 is really being an artist. 800 00:40:29,298 --> 00:40:32,748 There's a famous quote by someone named Don Knuth who's considered the father of 801 00:40:32,748 --> 00:40:35,228 modern computer science, which interestingly enough 802 00:40:35,228 --> 00:40:37,848 he's still alive and he's in this department, so it's kind of like you're 803 00:40:37,849 --> 00:40:39,130 804 00:40:39,130 --> 00:40:41,619 in the same department - you should go look him up, actually 805 00:40:41,619 --> 00:40:44,888 - with the father of modern computer science. And one of 806 00:40:44,889 --> 00:40:48,669 the things he said is that programmers tend to better if they subconsciously 807 00:40:48,668 --> 00:40:50,618 think of themselves as artists. 808 00:40:50,619 --> 00:40:52,309 When you're putting something together, 809 00:40:52,309 --> 00:40:55,069 don't think of it like you're doing a proof in math. 810 00:40:55,068 --> 00:40:58,128 It's important to figure out all the logical steps, but at the end of the day, you're 811 00:40:58,128 --> 00:41:00,909 putting something together that has an inherent beauty to it. 812 00:41:00,909 --> 00:41:03,969 And that's part of the real beauty of computer science. So 813 00:41:03,969 --> 00:41:08,088 I hope you enjoyed the journey. I hope you learned some stuff along the way. And I 814 00:41:08,088 --> 00:41:11,858 just wanna thank you for taking part in the little journey we had together. So 815 00:41:11,858 --> 00:41:12,578 good luck on the final exam.