[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:01.91,0:00:04.41,Default,,0000,0000,0000,,This video is a Redo for the MOOC. Dialogue: 0,0:00:04.58,0:00:07.03,Default,,0000,0000,0000,,Redo means do it yourself, Dialogue: 0,0:00:07.52,0:00:09.54,Default,,0000,0000,0000,,watch the video and do what is\Nshown step by step. Dialogue: 0,0:00:10.06,0:00:13.47,Default,,0000,0000,0000,,It is also an invitation to\Nlook at how we program. Dialogue: 0,0:00:13.72,0:00:17.68,Default,,0000,0000,0000,,I won't follow a precise script, Dialogue: 0,0:00:17.85,0:00:20.06,Default,,0000,0000,0000,,I will try to do it,\Nbut if I encounter bugs or Dialogue: 0,0:00:20.23,0:00:23.09,Default,,0000,0000,0000,,things like that, I'm gonna \Nhandle them as I go along. Dialogue: 0,0:00:24.87,0:00:29.13,Default,,0000,0000,0000,,In this video, the idea\Nis to program a little Dialogue: 0,0:00:29.30,0:00:32.04,Default,,0000,0000,0000,,language that you can find \Nin role-playing games like Dialogue: 0,0:00:32.21,0:00:35.93,Default,,0000,0000,0000,,"Dungeons and Dragons". \NFor example, Dialogue: 0,0:00:36.10,0:00:38.80,Default,,0000,0000,0000,,for the ones who have this \Nexpression, what Dialogue: 0,0:00:38.97,0:00:40.01,Default,,0000,0000,0000,,does this expression mean? Dialogue: 0,0:00:40.42,0:00:45.38,Default,,0000,0000,0000,,It means: you must throw 2\N20-sided dice and 1 4-sided. Dialogue: 0,0:00:45.55,0:00:47.42,Default,,0000,0000,0000,,You'll see it can be a Pharo\Nexpression. Dialogue: 0,0:00:48.00,0:00:52.49,Default,,0000,0000,0000,,So in this video we're going Dialogue: 0,0:00:52.66,0:00:55.17,Default,,0000,0000,0000,,to implement a class representing\Na die and a class Dialogue: 0,0:00:55.34,0:00:57.42,Default,,0000,0000,0000,,representing a handful of dice. Dialogue: 0,0:00:58.66,0:00:59.77,Default,,0000,0000,0000,,So let's begin. Dialogue: 0,0:01:00.87,0:01:04.29,Default,,0000,0000,0000,,We begin with defining a package. Dialogue: 0,0:01:05.71,0:01:06.79,Default,,0000,0000,0000,,We call this package "Dice". Dialogue: 0,0:01:06.96,0:01:11.86,Default,,0000,0000,0000,,I don't really want to see Dialogue: 0,0:01:12.03,0:01:16.66,Default,,0000,0000,0000,,other things. So in this Dialogue: 0,0:01:16.83,0:01:19.45,Default,,0000,0000,0000,,video I won't code in the Dialogue: 0,0:01:19.62,0:01:22.21,Default,,0000,0000,0000,,debugger, you've seen it in another\Nvideo, I will Dialogue: 0,0:01:22.38,0:01:24.41,Default,,0000,0000,0000,,do it on a case-by-case\Nbasis, in an opportunistic way. Dialogue: 0,0:01:25.49,0:01:30.03,Default,,0000,0000,0000,,Here I define the "Die" class\Nwhich Dialogue: 0,0:01:30.20,0:01:31.37,Default,,0000,0000,0000,,has a certain number of "faces". Dialogue: 0,0:01:32.10,0:01:35.63,Default,,0000,0000,0000,,I compile. I add a class comment. Dialogue: 0,0:01:43.38,0:01:45.89,Default,,0000,0000,0000,,For the moment, not much thing\Nbecause it is very very simple. Dialogue: 0,0:01:47.55,0:01:52.36,Default,,0000,0000,0000,,We are starting to enable our Dialogue: 0,0:01:52.53,0:01:53.95,Default,,0000,0000,0000,,object to be initialized. Dialogue: 0,0:02:00.45,0:02:02.26,Default,,0000,0000,0000,,I will do it like this. Dialogue: 0,0:02:10.19,0:02:13.56,Default,,0000,0000,0000,,I call for an initialization of \Nthe super-class, Dialogue: 0,0:02:13.73,0:02:18.14,Default,,0000,0000,0000,,by default I assign 6 faces \Nto my die because it is Dialogue: 0,0:02:18.31,0:02:19.14,Default,,0000,0000,0000,,the most common die. Dialogue: 0,0:02:19.82,0:02:22.53,Default,,0000,0000,0000,,Now I'm starting to \Ndevelop a Dialogue: 0,0:02:22.70,0:02:25.64,Default,,0000,0000,0000,,tests class, to be sure that what \Nwe do Dialogue: 0,0:02:25.81,0:02:26.90,Default,,0000,0000,0000,,doesn't break what has already\Nbeen done. Dialogue: 0,0:02:27.26,0:02:30.45,Default,,0000,0000,0000,,Tests classes are sub-classes of the \NTestCase class. Dialogue: 0,0:02:30.62,0:02:34.10,Default,,0000,0000,0000,,We call it "DieTest". Dialogue: 0,0:02:34.37,0:02:37.51,Default,,0000,0000,0000,,I have my tests class. Dialogue: 0,0:02:37.79,0:02:40.22,Default,,0000,0000,0000,,One of the first tests to do,\Nyou Dialogue: 0,0:02:40.39,0:02:42.48,Default,,0000,0000,0000,,don't have always to do it \Nlike this, but Dialogue: 0,0:02:42.65,0:02:46.65,Default,,0000,0000,0000,,in any case I want to begin with \Na test that works well. Dialogue: 0,0:02:47.84,0:02:52.12,Default,,0000,0000,0000,,As for the moment we don't have many \Nthings, I say that initialization is ok. Dialogue: 0,0:02:53.82,0:02:56.16,Default,,0000,0000,0000,,This is also a way to show you Dialogue: 0,0:02:56.33,0:02:59.77,Default,,0000,0000,0000,,how you can test that you can\Ncatch exceptions Dialogue: 0,0:02:59.94,0:03:01.44,Default,,0000,0000,0000,,or that exceptions mustn't\Noccur. Dialogue: 0,0:03:02.18,0:03:04.59,Default,,0000,0000,0000,,Here I am saying: Dialogue: 0,0:03:04.76,0:03:06.46,Default,,0000,0000,0000,,"Die new should not raise error". Dialogue: 0,0:03:18.12,0:03:19.17,Default,,0000,0000,0000,,What does it mean? Dialogue: 0,0:03:19.34,0:03:23.29,Default,,0000,0000,0000,,It means that when I execute this\Nbit of code "Die Dialogue: 0,0:03:23.46,0:03:25.60,Default,,0000,0000,0000,,new", no error must occur. Dialogue: 0,0:03:28.17,0:03:32.56,Default,,0000,0000,0000,,I'm gonna classify my test \Nand execute it. Dialogue: 0,0:03:32.73,0:03:35.55,Default,,0000,0000,0000,,It's green. All right. Dialogue: 0,0:03:36.00,0:03:40.02,Default,,0000,0000,0000,,So now, I'd like to define the Dialogue: 0,0:03:40.19,0:03:44.54,Default,,0000,0000,0000,,method that makes a die roll. Dialogue: 0,0:03:44.71,0:03:48.61,Default,,0000,0000,0000,,I know that in Pharo there must \Nbe a method Dialogue: 0,0:03:48.78,0:03:49.72,Default,,0000,0000,0000,,called "at Random". Dialogue: 0,0:03:49.89,0:03:53.94,Default,,0000,0000,0000,,At Random, what does it do? Dialogue: 0,0:03:54.48,0:03:57.78,Default,,0000,0000,0000,,It enables to have... Ok... Dialogue: 0,0:03:58.31,0:04:00.77,Default,,0000,0000,0000,,So now I look at the implementation\Nto be sure Dialogue: 0,0:04:00.94,0:04:03.62,Default,,0000,0000,0000,,it's ok. AtRandom, what does it\Ndo? Dialogue: 0,0:04:04.87,0:04:09.07,Default,,0000,0000,0000,,It returns an integer at random\Nfrom 1 to self, so it's perfect. Dialogue: 0,0:04:10.91,0:04:13.91,Default,,0000,0000,0000,,So I'm gonna define a new Dialogue: 0,0:04:15.29,0:04:19.22,Default,,0000,0000,0000,,method in Operations. Dialogue: 0,0:04:21.16,0:04:22.23,Default,,0000,0000,0000,,What will it do? Dialogue: 0,0:04:22.40,0:04:26.64,Default,,0000,0000,0000,,Roll. I say: "you return faces Dialogue: 0,0:04:27.57,0:04:28.20,Default,,0000,0000,0000,,atRandom". Dialogue: 0,0:04:35.75,0:04:37.40,Default,,0000,0000,0000,,So I write a test for this. Dialogue: 0,0:04:40.49,0:04:43.59,Default,,0000,0000,0000,,TestRolling. What do we do now? Dialogue: 0,0:04:44.12,0:04:49.04,Default,,0000,0000,0000,,We create a die. \Nd:= die Dialogue: 0,0:04:49.21,0:04:49.84,Default,,0000,0000,0000,,new Dialogue: 0,0:04:51.21,0:04:53.14,Default,,0000,0000,0000,,And now I write \N"1000 timesRepeat". Dialogue: 0,0:04:54.42,0:04:58.24,Default,,0000,0000,0000,,What? "d roll". Dialogue: 0,0:05:03.62,0:05:07.58,Default,,0000,0000,0000,,And I want this to be \Nbetween 1 and 6. Dialogue: 0,0:05:07.75,0:05:12.64,Default,,0000,0000,0000,,"Between: and:", it's Dialogue: 0,0:05:12.81,0:05:15.56,Default,,0000,0000,0000,,ok. "Between 1 and 6". Dialogue: 0,0:05:15.82,0:05:18.51,Default,,0000,0000,0000,,It is not very good\Nbecause here we created Dialogue: 0,0:05:18.68,0:05:22.47,Default,,0000,0000,0000,,a test only for 6-sided dice,\Nwe could have said Dialogue: 0,0:05:22.64,0:05:25.31,Default,,0000,0000,0000,,it works depending on the\Nnumber of sides of the die. Dialogue: 0,0:05:25.64,0:05:26.58,Default,,0000,0000,0000,,We will do it later. Dialogue: 0,0:05:26.83,0:05:27.46,Default,,0000,0000,0000,,So I compile. Dialogue: 0,0:05:32.84,0:05:35.62,Default,,0000,0000,0000,,I get an error. Here it is... Dialogue: 0,0:05:37.91,0:05:39.17,Default,,0000,0000,0000,,It is ok, I have my test. Dialogue: 0,0:05:39.34,0:05:41.46,Default,,0000,0000,0000,,Now it's time to save.\NHere I have my "Dice" Dialogue: 0,0:05:41.63,0:05:44.59,Default,,0000,0000,0000,,package, I save it locally,\N"Save". Dialogue: 0,0:05:44.76,0:05:49.00,Default,,0000,0000,0000,,I had created others before\Nto train a little so I Dialogue: 0,0:05:49.17,0:05:51.71,Default,,0000,0000,0000,,create a new one\N"New version with Dialogue: 0,0:05:56.53,0:06:00.78,Default,,0000,0000,0000,,rolling and test". All right. Dialogue: 0,0:06:01.03,0:06:02.37,Default,,0000,0000,0000,,Ok, it is saved. Dialogue: 0,0:06:11.48,0:06:14.61,Default,,0000,0000,0000,,Now I'd like to change Dialogue: 0,0:06:14.78,0:06:18.89,Default,,0000,0000,0000,,the creation interface.\NFirst we rearrange Dialogue: 0,0:06:19.81,0:06:22.20,Default,,0000,0000,0000,,categories. If we want to change \Na little the creation Dialogue: 0,0:06:22.37,0:06:26.39,Default,,0000,0000,0000,,interface. We say:\N"to create a die Dialogue: 0,0:06:26.56,0:06:28.09,Default,,0000,0000,0000,,use die faces". Dialogue: 0,0:06:39.29,0:06:42.61,Default,,0000,0000,0000,,On this expression you must see Dialogue: 0,0:06:42.78,0:06:46.03,Default,,0000,0000,0000,,that faces is a message sent to\Nthe die class and not Dialogue: 0,0:06:46.20,0:06:48.61,Default,,0000,0000,0000,,to an instance of die class,\Nas it is the case Dialogue: 0,0:06:49.09,0:06:51.88,Default,,0000,0000,0000,,in the roll method or in others\Nmethods coded until now. Dialogue: 0,0:06:52.05,0:06:55.04,Default,,0000,0000,0000,,I will do this for you to understand\Nwhen you Dialogue: 0,0:06:55.21,0:06:58.90,Default,,0000,0000,0000,,have to use and go to the class\Nlevel or not. Dialogue: 0,0:06:59.35,0:07:00.71,Default,,0000,0000,0000,,Let's begin by writing a test. Dialogue: 0,0:07:03.05,0:07:06.42,Default,,0000,0000,0000,,"betterInterface". Dialogue: 0,0:07:08.79,0:07:10.20,Default,,0000,0000,0000,,If I go on with the same logic, Dialogue: 0,0:07:12.23,0:07:18.08,Default,,0000,0000,0000,,"TestbetterCreationInterface", Dialogue: 0,0:07:18.25,0:07:20.95,Default,,0000,0000,0000,,Here I'd like to do something like\Nthis for instance, Dialogue: 0,0:07:22.68,0:07:23.64,Default,,0000,0000,0000,,and this to be faces. Dialogue: 0,0:07:30.62,0:07:32.42,Default,,0000,0000,0000,,I will do it slowly. Dialogue: 0,0:07:32.95,0:07:36.84,Default,,0000,0000,0000,,I go there and I type\N"instance creation", faces: , anInteger. Dialogue: 0,0:07:46.56,0:07:49.00,Default,,0000,0000,0000,,I could write it in a short way\Nbut here Dialogue: 0,0:07:49.17,0:07:50.53,Default,,0000,0000,0000,,I do it in a calm way. Dialogue: 0,0:07:51.00,0:07:52.94,Default,,0000,0000,0000,,I create a die. Dialogue: 0,0:07:53.89,0:07:57.74,Default,,0000,0000,0000,,I write "self new", as\Nself here is the die class itself. Dialogue: 0,0:07:58.22,0:08:00.41,Default,,0000,0000,0000,,I tell: "create an instance". Dialogue: 0,0:08:00.58,0:08:03.62,Default,,0000,0000,0000,,And now with this instance I\Nuse Dialogue: 0,0:08:03.79,0:08:08.41,Default,,0000,0000,0000,,an accessor to assign it the value\Npassed as an argument. Dialogue: 0,0:08:08.58,0:08:12.13,Default,,0000,0000,0000,,Obviously, I return the die\Nthat has just been created. Dialogue: 0,0:08:13.86,0:08:16.92,Default,,0000,0000,0000,,When the code will be executed,\Nit won't work because Dialogue: 0,0:08:17.09,0:08:19.95,Default,,0000,0000,0000,,faces doesn't exist, so don't \Nworry. Dialogue: 0,0:08:20.12,0:08:22.76,Default,,0000,0000,0000,,You see that the test isn't ok,\Nbut Dialogue: 0,0:08:22.93,0:08:27.72,Default,,0000,0000,0000,,it's normal, if I \Nexecute this Dialogue: 0,0:08:27.89,0:08:29.52,Default,,0000,0000,0000,,for example, if I do debug to see... Dialogue: 0,0:08:33.64,0:08:38.36,Default,,0000,0000,0000,,And I click on Over, here it\Nsays: "I don't know Dialogue: 0,0:08:38.53,0:08:41.43,Default,,0000,0000,0000,,the faces message." Dialogue: 0,0:08:41.91,0:08:45.77,Default,,0000,0000,0000,,Here we will do it calmly, I won't\Ndo it in the debugger. Dialogue: 0,0:08:46.83,0:08:49.60,Default,,0000,0000,0000,,I say: "that's true, I have \Nto add an accessor Dialogue: 0,0:08:52.91,0:08:57.39,Default,,0000,0000,0000,,here. So I write \Nfaces: anInteger. Dialogue: 0,0:08:57.56,0:09:01.52,Default,,0000,0000,0000,,And there I write : faces := anInteger. Dialogue: 0,0:09:05.02,0:09:08.11,Default,,0000,0000,0000,,And while I'm at it, I create \Nthe read accessor. Dialogue: 0,0:09:09.33,0:09:11.50,Default,,0000,0000,0000,,I return this one. Dialogue: 0,0:09:13.25,0:09:14.45,Default,,0000,0000,0000,,And here my test is green. Dialogue: 0,0:09:15.24,0:09:19.18,Default,,0000,0000,0000,,So we save, "save" Dialogue: 0,0:09:19.35,0:09:22.25,Default,,0000,0000,0000,,"better die creation\Nmethod with tests". Dialogue: 0,0:09:22.42,0:09:23.05,Default,,0000,0000,0000,,All right. Dialogue: 0,0:09:31.61,0:09:33.67,Default,,0000,0000,0000,,Now we can start to Dialogue: 0,0:09:33.84,0:09:37.65,Default,,0000,0000,0000,,define what we want for Dialogue: 0,0:09:38.69,0:09:42.05,Default,,0000,0000,0000,,diceHandle. Basically if we \Nlook, diceHandle, Dialogue: 0,0:09:42.22,0:09:44.00,Default,,0000,0000,0000,,how would we like to write it? Dialogue: 0,0:09:44.17,0:09:45.45,Default,,0000,0000,0000,,We would like to write\NdiceHandle new addDie. Dialogue: 0,0:09:49.30,0:09:53.29,Default,,0000,0000,0000,,So now we are going to create\Na new die, "die faces 6, addDie". Dialogue: 0,0:09:55.21,0:09:59.68,Default,,0000,0000,0000,,"Die faces 10". Dialogue: 0,0:10:07.26,0:10:12.04,Default,,0000,0000,0000,,We start to write a Dialogue: 0,0:10:12.21,0:10:13.58,Default,,0000,0000,0000,,test class, this time. Dialogue: 0,0:10:15.25,0:10:19.93,Default,,0000,0000,0000,,So a new class which\Ninherits from TestCase. Dialogue: 0,0:10:20.29,0:10:22.33,Default,,0000,0000,0000,,All right. I have my new\Ntests class. Dialogue: 0,0:10:24.00,0:10:26.73,Default,,0000,0000,0000,,And I define a test. Dialogue: 0,0:10:30.22,0:10:32.85,Default,,0000,0000,0000,,The idea is to create a\Nhandful and to Dialogue: 0,0:10:33.02,0:10:35.14,Default,,0000,0000,0000,,check there are the right dice\Nin it. Dialogue: 0,0:10:35.31,0:10:39.38,Default,,0000,0000,0000,,I write "testAdding", \NI want to reuse my Dialogue: 0,0:10:39.55,0:10:43.73,Default,,0000,0000,0000,,code, there is no reason otherwise. Dialogue: 0,0:10:45.53,0:10:48.06,Default,,0000,0000,0000,,So I have my Dialogue: 0,0:10:54.31,0:10:58.94,Default,,0000,0000,0000,,handle; yourself , because I \Nwant to Dialogue: 0,0:10:59.11,0:11:01.96,Default,,0000,0000,0000,,get the message receiver,\Nit is to say the handle Dialogue: 0,0:11:02.13,0:11:03.69,Default,,0000,0000,0000,,and not the argument that is here. Dialogue: 0,0:11:04.50,0:11:08.26,Default,,0000,0000,0000,,Now what should I do? Dialogue: 0,0:11:08.43,0:11:12.52,Default,,0000,0000,0000,,I write "self\Nassert h diceNumber Dialogue: 0,0:11:13.96,0:11:14.59,Default,,0000,0000,0000,,equals 2". Dialogue: 0,0:11:20.70,0:11:23.38,Default,,0000,0000,0000,,I compile. Obviously the system\Nsays: "I don't Dialogue: 0,0:11:23.55,0:11:25.93,Default,,0000,0000,0000,,know the DiceHandle variable. Do\Nyou want it Dialogue: 0,0:11:26.10,0:11:26.73,Default,,0000,0000,0000,,to be a class?" Dialogue: 0,0:11:26.90,0:11:27.96,Default,,0000,0000,0000,,Yes. It must be a class. Dialogue: 0,0:11:28.56,0:11:29.75,Default,,0000,0000,0000,,Here it will define it. Dialogue: 0,0:11:29.92,0:11:31.34,Default,,0000,0000,0000,,As I know that I have\Nto stop the dice anyway Dialogue: 0,0:11:31.51,0:11:36.44,Default,,0000,0000,0000,,I take this opportunity to Dialogue: 0,0:11:36.87,0:11:39.58,Default,,0000,0000,0000,,put an instance variable. Dialogue: 0,0:11:39.75,0:11:40.86,Default,,0000,0000,0000,,I compile all this. Dialogue: 0,0:11:41.79,0:11:45.72,Default,,0000,0000,0000,,Now it's red because "Add die" \Nhasn't been defined. Dialogue: 0,0:11:47.62,0:11:48.57,Default,,0000,0000,0000,,So we will do it. Dialogue: 0,0:11:48.74,0:11:51.62,Default,,0000,0000,0000,,Before doing this, it will\Nbe nice to initialise Dialogue: 0,0:11:54.24,0:11:56.66,Default,,0000,0000,0000,,the handle, so we do it like this,\Nit will prevent Dialogue: 0,0:11:56.83,0:11:57.89,Default,,0000,0000,0000,,to have a bug later. Dialogue: 0,0:12:02.89,0:12:04.56,Default,,0000,0000,0000,,dice : = OrderedCollection new. Dialogue: 0,0:12:04.73,0:12:05.36,Default,,0000,0000,0000,,Recategorize. Dialogue: 0,0:12:21.88,0:12:24.76,Default,,0000,0000,0000,,And now, I must be able to \Nrun my Dialogue: 0,0:12:24.93,0:12:27.73,Default,,0000,0000,0000,,test, which will crash. \NOk, very well. Dialogue: 0,0:12:27.90,0:12:30.20,Default,,0000,0000,0000,,I create Add die. Dialogue: 0,0:12:30.53,0:12:31.16,Default,,0000,0000,0000,,Adding. Dialogue: 0,0:12:35.33,0:12:38.03,Default,,0000,0000,0000,,It says: "You should implement\Nthis method." Dialogue: 0,0:12:38.20,0:12:39.08,Default,,0000,0000,0000,,Yes, it makes sense. Dialogue: 0,0:12:39.25,0:12:42.43,Default,,0000,0000,0000,,I write "Dice add aDie". Dialogue: 0,0:12:43.59,0:12:45.92,Default,,0000,0000,0000,,Ok, very good.\NMy test won't still Dialogue: 0,0:12:46.09,0:12:48.15,Default,,0000,0000,0000,,work because I still don't\Nhave defined the diceNumber Dialogue: 0,0:12:48.32,0:12:52.12,Default,,0000,0000,0000,,method, let's do it.\NYes, diceNumber, Dialogue: 0,0:12:52.29,0:12:56.78,Default,,0000,0000,0000,,we will create it, in\Naccessing this time. Dialogue: 0,0:12:57.35,0:12:58.80,Default,,0000,0000,0000,,And diceNumber,\Nwhat will it do? Dialogue: 0,0:12:58.97,0:13:00.33,Default,,0000,0000,0000,,It must return Dialogue: 0,0:13:06.29,0:13:08.11,Default,,0000,0000,0000,,dice size. I compile again,\Nproceed. Dialogue: 0,0:13:09.94,0:13:12.51,Default,,0000,0000,0000,,And my test should be green\Nso, the tests Dialogue: 0,0:13:12.68,0:13:14.86,Default,,0000,0000,0000,,are green and I save. Dialogue: 0,0:13:17.25,0:13:18.58,Default,,0000,0000,0000,,"With addDie and test". Dialogue: 0,0:13:24.56,0:13:28.09,Default,,0000,0000,0000,,We could improve the test because\Nhere Dialogue: 0,0:13:28.26,0:13:31.90,Default,,0000,0000,0000,,it checks that we add 2 numbers, \NI'd like Dialogue: 0,0:13:32.07,0:13:35.18,Default,,0000,0000,0000,,to check that when Dialogue: 0,0:13:35.35,0:13:37.61,Default,,0000,0000,0000,,we add twice the same die\Nwe don't lose it. Dialogue: 0,0:13:38.28,0:13:39.34,Default,,0000,0000,0000,,I write\N"TestAddingTwiceTheSame DieisOK". Dialogue: 0,0:13:49.04,0:13:50.29,Default,,0000,0000,0000,,Here what do I do? Dialogue: 0,0:13:50.46,0:13:54.53,Default,,0000,0000,0000,,I add 6 and 6 and I want to \Nget 2 Dialogue: 0,0:13:57.03,0:13:59.94,Default,,0000,0000,0000,,I do this I run my test,\Nit's green, super. Dialogue: 0,0:14:01.23,0:14:04.70,Default,,0000,0000,0000,,Now, it will be nice to be able Dialogue: 0,0:14:05.88,0:14:08.96,Default,,0000,0000,0000,,to define what it is to do Dialogue: 0,0:14:11.24,0:14:14.90,Default,,0000,0000,0000,,add 2 dice. But before this,\Nlet's do something. Dialogue: 0,0:14:15.07,0:14:17.21,Default,,0000,0000,0000,,If you look, what I don't like, Dialogue: 0,0:14:17.38,0:14:19.03,Default,,0000,0000,0000,,when I inspect this for example, Dialogue: 0,0:14:23.95,0:14:28.74,Default,,0000,0000,0000,,if I do "Inspect"\Nhere, I don't see Dialogue: 0,0:14:28.91,0:14:31.53,Default,,0000,0000,0000,,the dice values and it's not\Npractical to debug. Dialogue: 0,0:14:31.70,0:14:33.03,Default,,0000,0000,0000,,In the debugger, we don't see this. Dialogue: 0,0:14:33.37,0:14:36.09,Default,,0000,0000,0000,,So before going on, I want \Nto improve Dialogue: 0,0:14:36.26,0:14:38.37,Default,,0000,0000,0000,,this. I'm going to add\Na method Dialogue: 0,0:14:38.66,0:14:41.71,Default,,0000,0000,0000,,in the Printing protocol.\NThe "PrintOn" method Dialogue: 0,0:14:44.22,0:14:46.84,Default,,0000,0000,0000,,is defined on all the objects of\Nthe system and Dialogue: 0,0:14:47.01,0:14:50.38,Default,,0000,0000,0000,,it will convert an object to a Dialogue: 0,0:14:50.55,0:14:53.49,Default,,0000,0000,0000,,textual representation and Dialogue: 0,0:14:55.38,0:14:58.78,Default,,0000,0000,0000,,pass a stream. We will only precise Dialogue: 0,0:14:58.95,0:15:00.42,Default,,0000,0000,0000,,the representation we want\Ninside it. Dialogue: 0,0:15:01.89,0:15:03.50,Default,,0000,0000,0000,,If I do this, I've done nothing\Nin fact. Dialogue: 0,0:15:03.67,0:15:07.63,Default,,0000,0000,0000,,If I do super PrintOn, in fact I've\Ndone nothing. Dialogue: 0,0:15:07.80,0:15:09.23,Default,,0000,0000,0000,,Now I will do Dialogue: 0,0:15:09.40,0:15:13.22,Default,,0000,0000,0000,,"aStreamnextPut", so I will \Nput characters in the Dialogue: 0,0:15:13.39,0:15:15.22,Default,,0000,0000,0000,,stream, but what will I \Nput first? Dialogue: 0,0:15:16.09,0:15:18.33,Default,,0000,0000,0000,,I will write a parenthesis with a\Nspace, maybe it Dialogue: 0,0:15:18.50,0:15:19.88,Default,,0000,0000,0000,,will be nicer, a parenthesis. Dialogue: 0,0:15:20.45,0:15:23.55,Default,,0000,0000,0000,,Then I will consider faces\Nand convert them Dialogue: 0,0:15:23.72,0:15:27.78,Default,,0000,0000,0000,,in numbers, in strings, and\Nconcatenate all this Dialogue: 0,0:15:28.36,0:15:30.76,Default,,0000,0000,0000,,with a closing parenthesis. Dialogue: 0,0:15:31.15,0:15:34.93,Default,,0000,0000,0000,,If I do this... I closed the debugger,\Nso I open it again. Dialogue: 0,0:15:35.85,0:15:38.63,Default,,0000,0000,0000,,I have the debugger. Now\NI have a 6-sided die Dialogue: 0,0:15:38.80,0:15:40.48,Default,,0000,0000,0000,,and a 10-sided die. So it is \Nmuch Dialogue: 0,0:15:40.65,0:15:44.14,Default,,0000,0000,0000,,nicer, you will see, if we\Nencounter bugs, it will help. Dialogue: 0,0:15:44.85,0:15:48.14,Default,,0000,0000,0000,,So here I didn't do anything special,\Nmy tests are running. Dialogue: 0,0:15:49.45,0:15:53.34,Default,,0000,0000,0000,,I save again, it doesn't cost \Nmuch, "With printing". Dialogue: 0,0:15:55.22,0:15:56.40,Default,,0000,0000,0000,,We write "with die printOn". Dialogue: 0,0:16:03.03,0:16:08.00,Default,,0000,0000,0000,,All right. Now we create the\Ntest, we won't Dialogue: 0,0:16:08.17,0:16:09.58,Default,,0000,0000,0000,,do it, we will go \Ndirectly there. Dialogue: 0,0:16:10.08,0:16:12.49,Default,,0000,0000,0000,,We select "add\Nprotocol", "roll", "operations". Dialogue: 0,0:16:13.60,0:16:17.89,Default,,0000,0000,0000,,So, Dialogue: 0,0:16:18.06,0:16:22.53,Default,,0000,0000,0000,,there are several ways to define \Nthis. Dialogue: 0,0:16:22.82,0:16:25.04,Default,,0000,0000,0000,,I propose you one, this is not \Nthe nicest but Dialogue: 0,0:16:25.21,0:16:27.16,Default,,0000,0000,0000,,at least it is probably the \Nclearest for you. Dialogue: 0,0:16:27.53,0:16:29.13,Default,,0000,0000,0000,,There is a compact way, I could Dialogue: 0,0:16:29.30,0:16:31.49,Default,,0000,0000,0000,,do it in one line, but using \Niterators Dialogue: 0,0:16:31.66,0:16:33.15,Default,,0000,0000,0000,,like "Injected to", here I'm\Ngonna use a loop. Dialogue: 0,0:16:33.55,0:16:34.21,Default,,0000,0000,0000,,So what do I do? Dialogue: 0,0:16:34.38,0:16:36.86,Default,,0000,0000,0000,,I take a value that I \Ninitialize to zero. Dialogue: 0,0:16:37.39,0:16:42.32,Default,,0000,0000,0000,,Then I do a loop on all the dice,\Nand Dialogue: 0,0:16:42.49,0:16:47.12,Default,,0000,0000,0000,,for each loop step I get\Na die, and what am Dialogue: 0,0:16:47.29,0:16:47.92,Default,,0000,0000,0000,,I going to do with this die? Dialogue: 0,0:16:48.12,0:16:51.90,Default,,0000,0000,0000,,I ask it to get a die roll\Nand to add the result to Dialogue: 0,0:16:52.07,0:16:53.44,Default,,0000,0000,0000,,my variable. Dialogue: 0,0:16:55.64,0:17:00.31,Default,,0000,0000,0000,,Nothing very special but at least\Nit is very very explicit. Dialogue: 0,0:17:02.00,0:17:05.38,Default,,0000,0000,0000,,Now if I do "Inspect" and there Dialogue: 0,0:17:05.55,0:17:10.51,Default,,0000,0000,0000,,"Roll", 5, it doesn't prove\Nit is working. Dialogue: 0,0:17:11.21,0:17:12.14,Default,,0000,0000,0000,,Let's try once more. Dialogue: 0,0:17:12.31,0:17:13.14,Default,,0000,0000,0000,,11. Ok, it's working. Dialogue: 0,0:17:13.95,0:17:16.12,Default,,0000,0000,0000,,We are gonna try to write \Na test, there is Dialogue: 0,0:17:16.29,0:17:19.92,Default,,0000,0000,0000,,no reason, so we do \N"Test", I want to see this one Dialogue: 0,0:17:21.59,0:17:22.94,Default,,0000,0000,0000,,and I call it rolling. Dialogue: 0,0:17:26.96,0:17:30.94,Default,,0000,0000,0000,,So how do we have to do to test\Nthis? Dialogue: 0,0:17:31.11,0:17:35.76,Default,,0000,0000,0000,,It has to be between one and\Nthe maximum of the number of dice. Dialogue: 0,0:17:38.00,0:17:42.10,Default,,0000,0000,0000,,So we will do this. Dialogue: 0,0:17:42.27,0:17:42.90,Default,,0000,0000,0000,,We Dialogue: 0,0:17:48.28,0:17:49.93,Default,,0000,0000,0000,,could define a method\Ndoing this. Dialogue: 0,0:17:50.24,0:17:53.04,Default,,0000,0000,0000,,Let's create a method\Ndefining the maximum. Dialogue: 0,0:17:56.72,0:18:00.10,Default,,0000,0000,0000,,"Operation maxValue". Dialogue: 0,0:18:02.48,0:18:03.24,Default,,0000,0000,0000,,What is maxValue ? Dialogue: 0,0:18:03.41,0:18:05.02,Default,,0000,0000,0000,,It is very close to this. Dialogue: 0,0:18:05.78,0:18:10.00,Default,,0000,0000,0000,,Here instead of doing roll, Dialogue: 0,0:18:11.44,0:18:12.43,Default,,0000,0000,0000,,I will ask for the faces. Dialogue: 0,0:18:16.56,0:18:20.49,Default,,0000,0000,0000,,Let's check. If I do\N"Inspect", there Dialogue: 0,0:18:21.83,0:18:24.82,Default,,0000,0000,0000,,I do "maxValue", "16". Dialogue: 0,0:18:28.49,0:18:30.48,Default,,0000,0000,0000,,Yes, it's right 10 and 6. Dialogue: 0,0:18:30.65,0:18:33.09,Default,,0000,0000,0000,,So we write a test for Dialogue: 0,0:18:37.01,0:18:41.60,Default,,0000,0000,0000,,"maxValue". So I have this,\NI do "maxValue equal Dialogue: 0,0:18:41.77,0:18:42.40,Default,,0000,0000,0000,,16". Dialogue: 0,0:18:45.32,0:18:48.15,Default,,0000,0000,0000,,So here you see, I could have\Ncoded something Dialogue: 0,0:18:48.32,0:18:51.32,Default,,0000,0000,0000,,very dirty in my test, but\Nfinally, it is better Dialogue: 0,0:18:51.49,0:18:53.69,Default,,0000,0000,0000,,to create a method in the class\Nand to use it. Dialogue: 0,0:18:54.08,0:18:58.37,Default,,0000,0000,0000,,So now, we can test the\Nroll method Dialogue: 0,0:18:58.82,0:19:02.34,Default,,0000,0000,0000,,works well. Let's do \N"roll", Dialogue: 0,0:19:05.90,0:19:08.77,Default,,0000,0000,0000,,and say it must be comprised Dialogue: 0,0:19:08.94,0:19:11.00,Default,,0000,0000,0000,,between... "Roll between 1 and Dialogue: 0,0:19:14.23,0:19:15.69,Default,,0000,0000,0000,,h maxValue. Dialogue: 0,0:19:24.08,0:19:26.00,Default,,0000,0000,0000,,If I do this, ok it works. Dialogue: 0,0:19:28.12,0:19:30.87,Default,,0000,0000,0000,,This is not very statistical,\Nso here we could do Dialogue: 0,0:19:31.04,0:19:35.80,Default,,0000,0000,0000,,something like\N1 000 timesRepeat. Dialogue: 0,0:19:36.00,0:19:38.56,Default,,0000,0000,0000,,Ok. And there, Dialogue: 0,0:19:42.22,0:19:46.68,Default,,0000,0000,0000,,we have our 1000 tests. Dialogue: 0,0:19:47.74,0:19:49.33,Default,,0000,0000,0000,,Now we save. All right. Dialogue: 0,0:19:49.50,0:19:52.44,Default,,0000,0000,0000,,We save once more.\N"save" added maxValue Dialogue: 0,0:19:54.61,0:19:56.03,Default,,0000,0000,0000,,and roll with tests. Dialogue: 0,0:20:03.94,0:20:08.38,Default,,0000,0000,0000,,We've almost finished, Dialogue: 0,0:20:08.55,0:20:11.07,Default,,0000,0000,0000,,what we want to express now,\Nis Dialogue: 0,0:20:11.24,0:20:13.68,Default,,0000,0000,0000,,instead of having "die faces 6", Dialogue: 0,0:20:16.29,0:20:17.67,Default,,0000,0000,0000,,I'd like to have "1 D6". Dialogue: 0,0:20:17.84,0:20:18.47,Default,,0000,0000,0000,,And Dialogue: 0,0:20:25.51,0:20:27.63,Default,,0000,0000,0000,,what you see at the end is that\Nit means "send Dialogue: 0,0:20:27.80,0:20:31.05,Default,,0000,0000,0000,,the message 6 to a small integer". Dialogue: 0,0:20:31.77,0:20:34.54,Default,,0000,0000,0000,,So we go and look at the \Ninteger class. Dialogue: 0,0:20:34.71,0:20:39.62,Default,,0000,0000,0000,,What we are going to do is Dialogue: 0,0:20:39.79,0:20:43.66,Default,,0000,0000,0000,,to define a class extension. Dialogue: 0,0:20:43.83,0:20:45.01,Default,,0000,0000,0000,,What is a class extension? Dialogue: 0,0:20:45.89,0:20:50.35,Default,,0000,0000,0000,,I'm gonna package my methods\Nwith the same name as my package. Dialogue: 0,0:20:50.80,0:20:53.36,Default,,0000,0000,0000,,So you will see, what do I do?\NI add a Dialogue: 0,0:20:53.53,0:20:57.42,Default,,0000,0000,0000,,protocol, I put *, it must\Nstart with *dice which is Dialogue: 0,0:20:57.59,0:21:00.78,Default,,0000,0000,0000,,my package's name, automatically\Nthis is put in grey, and Dialogue: 0,0:21:00.95,0:21:02.90,Default,,0000,0000,0000,,it means the method will be \Npackaged Dialogue: 0,0:21:03.07,0:21:04.46,Default,,0000,0000,0000,,at the same time as this package.\NSo let's do it. Dialogue: 0,0:21:04.90,0:21:08.95,Default,,0000,0000,0000,,Let's imagine we do...\NWhat is D6? Dialogue: 0,0:21:10.00,0:21:13.57,Default,,0000,0000,0000,,A D6... I have to think \Na little about it... Dialogue: 0,0:21:21.05,0:21:24.25,Default,,0000,0000,0000,,We first create a handle because\Nit could Dialogue: 0,0:21:24.42,0:21:25.51,Default,,0000,0000,0000,,be 2 D6 finally. Dialogue: 0,0:21:27.21,0:21:31.93,Default,,0000,0000,0000,,So "handle", we do \N"diceHandle Dialogue: 0,0:21:32.10,0:21:32.73,Default,,0000,0000,0000,,new", Dialogue: 0,0:21:37.12,0:21:38.28,Default,,0000,0000,0000,,ok, so I have created my thing. Dialogue: 0,0:21:39.38,0:21:42.11,Default,,0000,0000,0000,,Now for each receiver, \NI will do Dialogue: 0,0:21:42.28,0:21:45.43,Default,,0000,0000,0000,,"self", this is my integer,\N"timesRepeat". Dialogue: 0,0:21:46.37,0:21:50.14,Default,,0000,0000,0000,,We will have really used a lot\Nthe timesRepeat, it's rare. Dialogue: 0,0:21:51.90,0:21:54.12,Default,,0000,0000,0000,,"TimesRepeat handle addDie", of what? Dialogue: 0,0:21:56.79,0:22:01.15,Default,,0000,0000,0000,,Of "die faces". And there, Dialogue: 0,0:22:02.00,0:22:03.72,Default,,0000,0000,0000,,we know it's 6. Dialogue: 0,0:22:05.89,0:22:09.83,Default,,0000,0000,0000,,And indeed, it would maybe be \Ngood to return the handle. Dialogue: 0,0:22:11.22,0:22:12.33,Default,,0000,0000,0000,,So does it work? Dialogue: 0,0:22:12.50,0:22:14.95,Default,,0000,0000,0000,,We're going to test like this and\Nwe write a test. Dialogue: 0,0:22:15.47,0:22:20.38,Default,,0000,0000,0000,,But if I do 2 D6, Inspect,\Nlook, Dialogue: 0,0:22:20.55,0:22:22.39,Default,,0000,0000,0000,,I do have 2 D6. So that's cool. Dialogue: 0,0:22:23.19,0:22:24.29,Default,,0000,0000,0000,,Let's write the test. Dialogue: 0,0:22:25.64,0:22:27.14,Default,,0000,0000,0000,,We will categorize those tests\Nafter all. Dialogue: 0,0:22:28.15,0:22:29.33,Default,,0000,0000,0000,,We write "testNewSyntax". Dialogue: 0,0:22:33.95,0:22:36.42,Default,,0000,0000,0000,,Here for the moment we only have\ND6, we will generalize later. Dialogue: 0,0:22:38.01,0:22:40.00,Default,,0000,0000,0000,,We want to do exactly the \Nsame thing Dialogue: 0,0:22:40.17,0:22:44.44,Default,,0000,0000,0000,,than this, so we will have\Nan handle, let's say 2 D6. Dialogue: 0,0:22:47.02,0:22:49.62,Default,,0000,0000,0000,,And there, we do\N"selfAssert". Dialogue: 0,0:22:53.31,0:22:54.43,Default,,0000,0000,0000,,What could we test? Dialogue: 0,0:22:54.60,0:22:56.47,Default,,0000,0000,0000,,That diceNumber equals 2 Dialogue: 0,0:23:02.88,0:23:05.42,Default,,0000,0000,0000,,for instance. So you've noticed\Nsometimes I use Dialogue: 0,0:23:05.59,0:23:09.16,Default,,0000,0000,0000,,diceHandle, I could have also\Nused = 2 here. Dialogue: 0,0:23:09.81,0:23:12.08,Default,,0000,0000,0000,,In general, it is nicer to use\Nassert equal Dialogue: 0,0:23:12.54,0:23:14.31,Default,,0000,0000,0000,,because like this, when there is\Nan error, the system Dialogue: 0,0:23:14.48,0:23:18.02,Default,,0000,0000,0000,,says: "I've received this and\Ngot this value instead of..." Dialogue: 0,0:23:18.63,0:23:22.91,Default,,0000,0000,0000,,If I write =, it will say:\N"I've got a wrong expression." Dialogue: 0,0:23:23.68,0:23:26.48,Default,,0000,0000,0000,,Here for the final user, who is \Nyourself, Dialogue: 0,0:23:26.65,0:23:28.85,Default,,0000,0000,0000,,as a developer, it is better\Nto use Dialogue: 0,0:23:30.58,0:23:33.34,Default,,0000,0000,0000,,assert equals because it will\Nsay: "I've received 3 whereas Dialogue: 0,0:23:33.56,0:23:34.68,Default,,0000,0000,0000,,I was expecting 2", for instance. Dialogue: 0,0:23:35.86,0:23:37.06,Default,,0000,0000,0000,,So here, I do this. Dialogue: 0,0:23:37.51,0:23:38.78,Default,,0000,0000,0000,,Ok, it works. Dialogue: 0,0:23:39.32,0:23:41.94,Default,,0000,0000,0000,,Could we have a smarter Dialogue: 0,0:23:42.11,0:23:43.09,Default,,0000,0000,0000,,version of this test? Dialogue: 0,0:23:43.26,0:23:44.24,Default,,0000,0000,0000,,For the moment, it suits us. Dialogue: 0,0:23:44.86,0:23:46.64,Default,,0000,0000,0000,,You see that now in Dialogue: 0,0:23:46.81,0:23:50.20,Default,,0000,0000,0000,,the package, I have an extension\Ncalled D6. Dialogue: 0,0:23:50.69,0:23:55.48,Default,,0000,0000,0000,,We will generalize this\Nwith Dialogue: 0,0:23:56.12,0:23:57.55,Default,,0000,0000,0000,,"aNumberOfFaces" Dialogue: 0,0:24:01.36,0:24:03.87,Default,,0000,0000,0000,,So "aNumberOfFaces", \Nwe put it there. Dialogue: 0,0:24:05.20,0:24:08.00,Default,,0000,0000,0000,,And we rewrite D6 because it would\Nbe better. Dialogue: 0,0:24:08.14,0:24:12.58,Default,,0000,0000,0000,,We write D6 like this. We do Dialogue: 0,0:24:12.75,0:24:16.66,Default,,0000,0000,0000,,returns self D6. Dialogue: 0,0:24:19.05,0:24:20.75,Default,,0000,0000,0000,,We do all the other ones. Dialogue: 0,0:24:20.92,0:24:24.37,Default,,0000,0000,0000,,We do 4, Dialogue: 0,0:24:26.02,0:24:30.87,Default,,0000,0000,0000,,2. It's more a coin than a die,\Nbut 2, Dialogue: 0,0:24:31.22,0:24:35.64,Default,,0000,0000,0000,,10 and 20. Dialogue: 0,0:24:36.44,0:24:37.57,Default,,0000,0000,0000,,You've understood the principle. Dialogue: 0,0:24:41.54,0:24:45.93,Default,,0000,0000,0000,,So let's run the tests, as we've\Nchanged the implementation. Dialogue: 0,0:24:47.01,0:24:49.37,Default,,0000,0000,0000,,2 D6... it means it works. Dialogue: 0,0:24:49.83,0:24:50.69,Default,,0000,0000,0000,,So let's save. Dialogue: 0,0:24:59.67,0:25:03.32,Default,,0000,0000,0000,,What is there still to do? Dialogue: 0,0:25:03.68,0:25:08.03,Default,,0000,0000,0000,,In fact, we have still to be able\Nto add the handles. Dialogue: 0,0:25:09.30,0:25:11.60,Default,,0000,0000,0000,,What tests do I want? Dialogue: 0,0:25:11.77,0:25:14.64,Default,,0000,0000,0000,,For instance, I want to be sure \Nif I do Dialogue: 0,0:25:18.71,0:25:23.24,Default,,0000,0000,0000,,"addingHandles", Dialogue: 0,0:25:23.41,0:25:25.59,Default,,0000,0000,0000,,(I can use the new syntax, Dialogue: 0,0:25:25.76,0:25:26.44,Default,,0000,0000,0000,,so it's nice) Dialogue: 0,0:25:26.96,0:25:28.94,Default,,0000,0000,0000,,I want to test that if Dialogue: 0,0:25:29.11,0:25:33.82,Default,,0000,0000,0000,,I write 2 D20 + 3 D5 Dialogue: 0,0:25:34.00,0:25:38.57,Default,,0000,0000,0000,,or 3 D6 instead (don't start to complicate Dialogue: 0,0:25:38.74,0:25:42.05,Default,,0000,0000,0000,,things). How much should I get ? Dialogue: 0,0:25:43.16,0:25:46.77,Default,,0000,0000,0000,,diceNumber should be equal to 5. Dialogue: 0,0:25:48.18,0:25:52.27,Default,,0000,0000,0000,,So here you see that we have to define\Nthe + operator. Dialogue: 0,0:25:52.87,0:25:55.52,Default,,0000,0000,0000,,In Pharo + isn't an operator, \Nit's just a message. Dialogue: 0,0:25:55.69,0:25:59.23,Default,,0000,0000,0000,,So we define a message on the \NDiceHandle class. Dialogue: 0,0:26:00.53,0:26:02.85,Default,,0000,0000,0000,,We write +. Dialogue: 0,0:26:04.65,0:26:05.52,Default,,0000,0000,0000,,So "aDiceHandle". Dialogue: 0,0:26:07.53,0:26:09.41,Default,,0000,0000,0000,,Now we can wonder if Dialogue: 0,0:26:09.58,0:26:11.77,Default,,0000,0000,0000,,we modify the receiver or \Neither if we use Dialogue: 0,0:26:11.94,0:26:12.84,Default,,0000,0000,0000,,a functional approach. Dialogue: 0,0:26:13.13,0:26:14.74,Default,,0000,0000,0000,,I prefer to use a functional approach Dialogue: 0,0:26:14.91,0:26:17.47,Default,,0000,0000,0000,,in which we create\Na new handle. Dialogue: 0,0:26:20.18,0:26:23.69,Default,,0000,0000,0000,,So I'm gonna create a\Nnew handle, I write Dialogue: 0,0:26:26.06,0:26:27.65,Default,,0000,0000,0000,,"handle self class new". Dialogue: 0,0:26:29.54,0:26:34.06,Default,,0000,0000,0000,,Here I avoided to write\NdiceHandle and later there Dialogue: 0,0:26:34.23,0:26:36.36,Default,,0000,0000,0000,,will be a lesson explaining why. Dialogue: 0,0:26:36.53,0:26:37.77,Default,,0000,0000,0000,,I prefer, it's closer. Dialogue: 0,0:26:37.94,0:26:39.80,Default,,0000,0000,0000,,In general you don't hard-code\Nthe classes' name. Dialogue: 0,0:26:40.43,0:26:42.53,Default,,0000,0000,0000,,You will see it in week 7 or\Nsomething like this, Dialogue: 0,0:26:42.70,0:26:44.04,Default,,0000,0000,0000,,there is a complete explanation. Dialogue: 0,0:26:44.74,0:26:49.66,Default,,0000,0000,0000,,If I do "self\Ndice do", I Dialogue: 0,0:26:49.83,0:26:53.48,Default,,0000,0000,0000,,iterate on my dice\Nand I add them in handle. Dialogue: 0,0:26:53.65,0:26:55.61,Default,,0000,0000,0000,,So I do \N"handle addDie each", Dialogue: 0,0:26:59.78,0:27:03.66,Default,,0000,0000,0000,,and I do the same...\NHere I don't Dialogue: 0,0:27:03.83,0:27:05.72,Default,,0000,0000,0000,,need self and in fact I don't\Nknow Dialogue: 0,0:27:05.89,0:27:07.42,Default,,0000,0000,0000,,the message, that's what it was\Ntelling me, and Dialogue: 0,0:27:07.59,0:27:09.37,Default,,0000,0000,0000,,it makes me notice that, indeed,\NI haven't defined it Dialogue: 0,0:27:09.82,0:27:12.79,Default,,0000,0000,0000,,and it hasn't worked for\N"diceHandle", but Dialogue: 0,0:27:15.63,0:27:20.48,Default,,0000,0000,0000,,no matter, let's compile first\Nand we'll fix it later. Dialogue: 0,0:27:21.23,0:27:22.45,Default,,0000,0000,0000,,So here, what does it mean? Dialogue: 0,0:27:22.62,0:27:24.79,Default,,0000,0000,0000,,It means it lacks an accessor,\Ndice. Dialogue: 0,0:27:25.28,0:27:28.77,Default,,0000,0000,0000,,So we add dice here,\Ndice returns Dialogue: 0,0:27:28.94,0:27:32.06,Default,,0000,0000,0000,,the collection of my dice. Dialogue: 0,0:27:32.23,0:27:35.28,Default,,0000,0000,0000,,Now I'm gonna test, see if\Nmy test is ok. Dialogue: 0,0:27:35.70,0:27:38.69,Default,,0000,0000,0000,,My test is ok, it's super, it\Nmeans I have Dialogue: 0,0:27:38.86,0:27:43.61,Default,,0000,0000,0000,,almost finished, I save,\N"with handles Dialogue: 0,0:27:44.81,0:27:46.69,Default,,0000,0000,0000,,additions". Ok, all right. Dialogue: 0,0:27:49.82,0:27:53.77,Default,,0000,0000,0000,,It means now we can write Dialogue: 0,0:27:57.30,0:28:02.21,Default,,0000,0000,0000,,2 D4 and we Dialogue: 0,0:28:02.38,0:28:06.38,Default,,0000,0000,0000,,can do "Roll", and it returns\Na number. Dialogue: 0,0:28:08.00,0:28:10.40,Default,,0000,0000,0000,,Now you are ready to play\N"Dungeons and Dragons". Dialogue: 0,0:28:11.20,0:28:15.87,Default,,0000,0000,0000,,What you have to know:\Nwe defined Dialogue: 0,0:28:17.57,0:28:19.48,Default,,0000,0000,0000,,our methods, we defined\Nour tests, we run Dialogue: 0,0:28:19.65,0:28:23.01,Default,,0000,0000,0000,,them, we extended a system \Nclass, Dialogue: 0,0:28:23.18,0:28:27.00,Default,,0000,0000,0000,,the integer class, with extensions\Nlinked to our Dialogue: 0,0:28:27.17,0:28:30.59,Default,,0000,0000,0000,,package, which will only be visible\Nwhen our package will be loaded. Dialogue: 0,0:28:32.29,0:28:34.58,Default,,0000,0000,0000,,We also overloaded operators,\Nbut Dialogue: 0,0:28:34.75,0:28:39.32,Default,,0000,0000,0000,,in fact we only defined a new \N+ message, because Dialogue: 0,0:28:39.49,0:28:43.60,Default,,0000,0000,0000,,in Pharo the addition is\Njust another message, Dialogue: 0,0:28:43.77,0:28:48.16,Default,,0000,0000,0000,,this enabled us to \Nexpress quite easily a nice DSL. Dialogue: 0,0:28:49.90,0:28:50.85,Default,,0000,0000,0000,,So now it's your turn to code!