Transcript for:
Week 3: Object Collaboration in Programming

All right, good morning everyone. How are you guys doing? Good?

So far? No. Are you catching up with the unit, mister? Yes?

Do you know that we are actually in week 3 right now? Yes, right? So today marks the official entering into week 3. So meaning that you have gone through week 1 and week 2 materials with me. So by right now, you should be very familiar with the software and you should understand what is actually a class.

All right. OK, so can you share with me what do you learn? last two weeks anyone you don't tell me you learn nothing god not oh yeah last week you learned unit 10 right but when you first entering into the class i actually tell you that there are two way in a program implementation one is the procedural way another way is an object oriented way am i right okay so for this particular unit which way are you learning Object-oriented, right? Okay, so you're learning object-oriented in solving a problem.

So that's the reason why every time when you are given a question, you always start with identifying what are the objects involved. Am I right? Okay, so what are the two things that contain within an object? So for instance, an object knows things, right?

And that is what in programming we know it as attributes of view. Do you agree? yes so an object will be able to do things perform certain operations or we known it as a method of behavior do you agree okay so in programming in order for you to create an object you will need to define the class okay so what is a class a class is actually a template right a template for object creation do you agree Okay, so when we talk about object, we will have attribute or field, we will have method or operation. So under method or operations, right, so we have three different types of methods or operations. The first one is what we known as a constructor.

Am I right? So why do you need to have a constructor to construct what? object, right? Imagine you have a class but there is no constructor inside.

How are you going to build an object out from the class? Cannot. Do you agree? Right? So what is so special about constructor?

Because it is having the same name as the class and it has no return type. This is how you identify that that is a constructor. Is it clear? Okay, now other than constructor, then you will have another type of method called property. So what is a property?

Or why do we need to have a property? Anyone? Even if you keep quiet, but inside your heart you have the answer and your answer is correct, then that is sufficient enough. Okay, but you have to ask yourself, do you have the answer? I don't know.

I cannot see. Okay. I cannot examine, I cannot see.

Right? So you will need to have a property in order to assess your private field. Do you agree?

Because in every classes that you define, the attributes of field, majority of them are actually with private assess specifier. So when it is private, in order to allow other classes to be able to assess to it, you will need to have a property. Is it clear? Okay.

And the third method that we are having here is the normal method, which is the method with written type or the method without a written type. Is it clear? Everyone? Yes.

Any questions so far? No. So in week two, what we are learning is we are learning unique has Okay, I told you, I teach you the significance of having unit tests.

So why do we need to have a unit test in order to test the methods that we have created within a particular class? So let's say you have one class and inside you have five different methods. How do you know whether these five different methods are being tested correctly or have been implemented correctly? The only way you can check on it is to create a unit test for each of the methods and test it out.

Okay. And of course, in order for us to create a unit test in C sharp, we need to add the right packages into it. Right.

So there are four different packages that you have to write, or you have to add it into your project file. You do so. Okay. And in order to use the packages, we need to include the library using nunit.framework.

So this is what we learned last week. Clear? Yes. It does not return the value because new is to build an object.

It is not supposed to give a new value. The keyword new here is to assign, to tell the compiler to assign a new memory slot for that particular object declared. okay so don't confuse with that okay get it everyone so far so good so we're going to move on to week three so whatever things you learn today you will see that it is growing okay if you are still finding yourself very messy about week one and week two i think the letters you have to pick up your week one and week two is by this week if you try to accumulate them and study only or look at it only on week four it might be a little bit too late. Clear?

Okay, so I'm serious here. So I'm not joking. All right. Okay, good.

So this particular week here, we actually going to learn on object collaboration. Okay, we're going to learn on object collaboration. So like I tell you in the first class, all right, in order to solve a comp, tax problem.

We cannot solve that problem by having only one single class. Do you agree? Okay, we cannot have a student class and expect that student class will be able to solve the entire student enrollment system program. Okay, so this is where this particular week about is we are trying to look at how does or what are the different ways that object can collaborate.

to achieve certain goals. Therefore, this week's chapter is about object collaboration. I'm not going to repeat what I have put or what I've recorded in the lecture slides, so you can watch that on the course. But I will focus on the summary, on what are the important things that you must know. So what you see right in front of you here is a class diagram.

A very high level class diagram here because it does not contain any much more information about the fields or the operation. Whatever you can see right here, we only can see that there are a series of classes working with each other. So let's say today I ask you to build a monopoly game using an object-oriented approach.

So the first thing that you will need to see, or you will need to identify what are the objects involved in that particular program. So in this case here, we have a die, which is a singular noun for dice. We have a die, we have a monopoly game, we have a board, we have a player, we have a piece, and we have a square here that you can see right in front of you here. And all these classes that you see here, they actually talk to each other. Okay?

For example, one Monopoly game will have to play with two dice here. Okay? And one Monopoly game is played on a particular board. Right? And a board will contain 40 squares.

One board will contain 40 squares. Okay? And then, where are the pieces? The pieces are...

is on the square and player has the pieces This is how you look in terms of solving a problem in an object-oriented way. So you have multiple classes, right? Each of the classes, you need to connect them in some way.

So the connections between each of the classes here is what we know as object collaboration. Another way, it is also known as object relationship. Looking in terms of relationship So there is somehow some tie or some relations between these classes. Okay, so in order to build a monopoly game, we need to have a total of six classes as been drawn here. And every of the classes that you identify here must indicate the field and the method for operations and indicate their relationship between each of the classes.

Is it clear? The first contact? Alright, now So these notations, are you familiar with this notation?

Anyone having any questions about this notation here? A rectangle is represent a class partitioned into three segments, right? First segment is the class name. Okay, second segments are the attributes of view.

And the third segments are the methods of operation. How do you write each one of them here, you will have a public plus protected hash, hash tag, and then you will have your private which is your minus here, followed by the attribute names, and the attributes field type or data type here, you will have a set of methods represents underneath as the operation. Is it clear up to here?

Okay, so this notation. Now, the next thing There are three main kinds of units, right, or three main kinds of relationships that we are going to focus on today. We have a total of three different types of relationships that we are going to focus on today. So today, when you exit the room, make sure you know how to differentiate these three types of relationships. The first type of relationship is what we know as an association.

relationship. Association relationship. The second type of relationship that we have here is what we know as aggregation.

The third type of relationship here is what we know as dependency. Your goal today is to leave the room able to explain these three types of relationship. You get it? Okay.

So, associations. In English, we know it as has a. A has a B.

Class A has class B. Aggregations here is what we know as is a part of. A is a part of B.

Dependency here is referring to users. A uses. V that is known as a dependency first level.

Get it? Okay now association you see right in front of you here. So there are two classes instructor and student.

So what is the relationship between instructor class and student class here? So obviously instructor teaches or instructs students. Means instructor is having a lot of students.

You get it? So the relationship to connect between instructor class and student class is an association relationship which is a straight line. Get it?

Sometimes you will want to indicate the cardinality or we know it as the multiplicity. For instance, one instructor can instruct one to many students. You can put the cardinality there or the multiplicity there. I don't know how many of you have learned database before you come into my unit. Some of you might not have, all right, but for those students who have already learned database, you shouldn't confuse with the concept that you learned in your ERD because it's a totally different thing.

Okay, right, test A. Any questions? Any questions on association?

No? Second one. aggregation. Okay, now under aggregation, it's been split into two different types. One is known as a shade aggregation.

Another one is known as a composition. All right, so under aggregation, there are two types. So for shade aggregation, it is representing a part of. So when I say team and player class, what is the relationship between these two classes? I can read it as player is a part of team.

Or I can say team is made up of players. Do you agree? But what is the difference between shared aggregations and composition?

If I destroy a team or I cancel a team, the player can still exist as a standalone object. Do you agree? If I say today I demolish the team for team B, does it mean the player will also die together with the team or the player can exist as a standalone entity?

it can exist as a standalone entity right so if you have that type of relationship is what we known as a shade aggregation and this is the symbol to represent shared aggregation you will have a line and a diamond okay the diamond will always connected to the whole section hola so this is the part this is the whole the entire theme okay so player is a part of team. Do you get it? Do you get it everyone?

Okay now composition. What's the difference in compositions? You have car, you have engine. So engine is a part of car.

Car owns the engine. If you burn down a car, the engine will go together with the car. gone do you get it that's how our relationship is what we known as composition is it clear is it clear everyone yes huh yes huh no need to feel scared because it's the first time you see this okay but you have to make sure that when you yourself go back home you read or you look at the lecture notes you know what is that get it yeah all right now the third relationship is dependency player and die die is a singular form of dice you know the dice that you roll okay player and die so what is the relationship between player and die i cannot say that player has a die all right I cannot say that die is a part of player or player is a part of die.

Do you agree? But what is actually the relationship between player and die is player uses die. Alright, when I say player uses die, it means that player will have a behavior then that behavior or that operation will involve the use of die.

all right will involve the use of die here now the further explanation to this will be every player will be able to roll a die every player will have a behavior of rolling a die so when player execute the method roll a dice this method roll a die involve the use of die class or the dice class here so this type of relationship is what we're known as dependency do you understand this is the most lemon way that i can tell my student is this way you know what i mean all right now every time when i give you two classes right you will always start with association. This is one thing you have to bear in mind. Every time when I give you two classes, you want to connect them, determine the relationship in between them.

You will always start with association. Why? Because you look back. Player has a die, looks correct. Okay?

Okay? And then, Car has an engine. Does it sounds correct?

Sounds correct. Okay? Team has player. Sounds correct? Correct.

then instructor has students also sound correct so that's the reason why every time when i give you two class the most basic of relationship that exists between these two cars is what we known as association but your role as a designer is to drill down deeper right on is this relationship a shape aggregation or is this relationship a composition right if there are no Is this relationship a dependency? You are going to drill down to the exact and right relationship. If there are neither shared aggregation, there are neither composition, there are neither dependency, meaning that the relationship is association.

Is it clear? Yeah? Everyone, huh? So, how many types of relationships do you learn this morning?

three right the first one is association the second one is aggregation the third one is dependency under aggregation it's been further split down into two one is a shared aggregation another one is a composition so the difference between shared aggregations and compositions you look at the symbol one is loosely tight that means another one can exist without the other one okay the other one there is composition here is what we have a darkened diamond so this one means arms okay for instance your hand and your body is it a shared aggregation or a composition your hand and your body and and your it is a composition do you agree it is actually a part of your body but if you destroy your body your hand will also gone at the same time do you get what i mean guys okay let's try out a few example now tell me what is the relationship between persons and passport person class and passport class person and passport okay dependency will answer for every type of relationship okay so what is that so i can say person has passport it sounds correct okay can i say passport is a part of person i don't know my password is not part of me definitely it's not is it a part of you no right so share aggregation or aggregation that part thrown away Can I say person uses passport? Yes, maybe. Why? If let's say I'm designing a system which is something to do with processing passport, then every person will have an operation called submit a passport.

So when you submit a passport, you need to use the passport, right? So it can be called as a dependency. You see this how you drill down.

Next example, house and room. house and room okay composition two votes but by the rest house and room association okay you need to drill down deeper generation so house and room so i can say that house has many room all right okay so i told you that every relationship will start with association Then the next one is, is room a part of house? Yes. So is it a shared aggregation or is it a composition? If you destroy the house, does the room exist?

No. So it will be composition. Get it?

Next, airplane and passenger. Airplane plus and passenger. dependency, I will share aggregation, composition, share aggregation.

Okay, I can say airplane has many passengers. I say it's very general has many passengers, right? Can I say passenger is a part of airplanes?

If let's say this is a airline reservation system. So can I say within an airplane, there is a passenger is actually a part of airplane no no so if i want to check whether this particular airplane carries how many passengers who are the passengers that is being carried cannot does airplane need to know that like for instance you go for a trip right you sit inside a flight okay so does the flight need to know the passenger details yes so somehow when you interpret it that way passenger is actually a part of the airplane right again again i'm trying to restructure you uh again i can say that if let's say this particular system is specifically used for airplane manufacturing manufacturing airplane then passenger is a part of airplane does not answer Because the airplane itself, the body, the wing, right, is actually a part of airplane, but not passenger. Do you see it's based on the domain that you saw?

All right. Now, if I were to say that I'm doing a flight, right, reservations or airline reservation system, so I can say that passenger is a part of airplane, but the relationship will be shared aggregation, but not composition. Composition means that if the airplane is too old, I want to stop using it, the passenger will go on as well together with the airplane, which it doesn't make sense in that way.

So the correct relationship will be either shared aggregations or you want to design in a way that it is an association. Now the third one, library and books. Library and books.

Shared aggregation correct books is a part of library. That's not composition. Okay now manager Airplane users passenger Passenger users airplane.

Yes, you can do that, right? It will be the other way around. Okay. Now the next example would be manager scheduler manager class and another one is scheduler so what's her relationship with that you know what scheduler help you to schedule your timetable your schedule all those things so sorry dependency anyone else dependency.

So manager uses scheduler doesn't make sense. So every time manager wants to perform at schedule or at time slot, it will use the scheduler object to do it to perform it for you. So that's how relationship is what we known as dependency.

So take a slight look on the symbol to represent dependency, you will have a dash arrow. Do you get it? Clear everyone? Hello? Yes?

Okay, one last thing before we move to quotes. So just like you say about house and room, the relationship is composition, right? So let me ask you, the diamond, the darkened diamond should be attached to house or should it attach to room?

Wow, very good. How's that? So make sure when you submit your work, it is attached in the right section, in the right class. So it will always attach to the whole site.

Is it clear? Conceptually, everyone understands. Yes. After this class, we'll still be able to remember. There's a different story.

okay all right now let's move on yeah share my entire screen let's have a look at this yeah okay all right i'll allow you to take photo first can you take a photo of this first Now, how many classes can you see right in front of you here? Two, very good, confidently. So do you see you are growing? Not you are growing, actually, you grow every day.

The class is growing. Do you see that? The question is growing, right?

So you can imagine that by the time you reach week six, right, how many classes can you find in one page? Six. Many, many. Uncountable, all right?

So today we try to expand a little bit by looking something that is more than one single class here. Okay, so there are two classes here. One is known as course.

Another one is known as unit. All right. Okay, don't do anything.

Don't have anything first, but understand first. You need to build some feelings and relationship with the question, right? Then only then you can move forward. So you have a unit class having three fields here. Agree?

Yes? You have a constructor. Agree? You have a property, available property.

And you have a print details method. Agree? Good.

You have another class called course. You know your course? Like your Bachelor of Computer Science, Bachelor of Robotics and Mechatronics.

So this is course. Course is having three fields. Name, ID, and units.

You see the units here is plural, right? The data type for name is string. The data type for ID is int. And the data type for units is something new that you learn this week.

It's called a list. Okay, what is a list? I'll explain later. All right, you have a list.

So, every course... will have many units. Do you agree? Right? So, for example, Bachelor of Computer Science, you will need to study 24 units to graduate.

Okay? So, under the course class, you will have a constructor, right? You will have an addUnit method that will receive a unit object. You will have a removeUnit method that will receive a unit object to remove that unit from the course.

Okay, you will have a number of unit method that will return to the number of units inside that course. Okay, right, you will have a display method, which is to print out all the detail of the course. Do you understand at this point of time? Yes.

Clear. No questions. Okay, good.

So now the next thing that I'm going to show you is this. I need everyone to have full concentration from this because I will explain only once. Okay, can you see?

This is the biggest I can go. Okay, all right. Now you learn array.

Am I right? Okay, now when you come into this unit, you are going to learn this what is the difference between array and list okay so array meaning that you can declare a variable right and that variable can use to refer multiple positions right so for instance you need subscribe subscribe underscore units equals to new unit 3. I believe that I explained this in the first lab demo that you see, okay, when you are two weeks younger than now. If you still remember, correct or not, two weeks younger than now.

I explained this in my lab demo. If you watch now, meaning that you are a bit later, okay? So, when I write this line, it means that I'm creating this.

Am I correct? The first lot is unit 0. underscore unit zero, underscore units one, and underscore units two. Does it make sense?

If you are lost, being that danger, you know, it's a sign of danger if you are lost. Now, when I say underscore unit zero, the first one, equal to new, when I've used the keyword new, means I'm telling the compiler, build that object up. New what? new unit OOP 1000 and true. So meaning that in my first slot here, I will have a unit object with the code equals to 1000, the name equals to OOP and the available equals to true.

Does it make sense? Does it make sense? Okay, if I want to build the first one, what should I write?

I will have underscore unit one. equals to new unit something something else that you want to throw it in agree so i have three here by right i have to write how many times of this three times one for the first slot one for the second plot one for the third slot agree in the middle of the running of the program can i change the size to become four can i change the size to become five no For array, you cannot increase the size. If you declare it as 3, it will forever be 3. You cannot say halfway running the program, I change the size, become 4, become 5, become 6. Cannot.

Because array is a static variable. It does not allow increment of size once you declare it. This is a shortfall. Okay? That is the reason why we have lift.

okay please allow us to create an array that is dynamic mean the size can grow or shrink as it like you don't have to indicate what is the size of the array at the very beginning you don't need to indicate that okay so this is how you declare a list here okay so you will have the variable name, right? The type is not int, it's not double, it's not string, the type is a lead, right? So what type of object you want to put inside that list, the list, this list, I want to put unit object. That's why you see between this open bracket and closed bracket, you have a unit inside.

Do you get what I mean? Okay, now When you write this particular line that you see here, the first line that you see here, this particular part that you see here, right, you will notice that that particular sentences or that particular line of code is actually telling the compiler that okay, please get ready, I'm going to create a list, an arrow, right a pointer, which is known as underscore units. But is this arrow going to point to any way?

Not yet. Not yet. the second line that you see here underscore units equals to new new what new list unit bracket meaning that you are calling the constructor of the list to build that particular list up okay so it will create something like this some look how long is the slot don't know because it's dynamic you did not fix it right anything inside Nothing. Nothing inside.

You got it? So these two lines is building something like this. This is how I like to explain to my students in a visual way.

Because you cannot imagine, I think. Last time when my lecturer teach me, they always teach me to imagine how does it look like. A lot of bubbles here.

So now I draw it out for you. Make sure that you yourself know how to interpret your own code. So the next line that you see here. is a unit underscore unit one equals to new unit. This is nothing new to you.

It means that you are creating a unit one object. That's all. Okay, so now I want to add this unit one into my list.

So I will have underscore units dot add super powerful thing about this is there are a lot of library there's dot add dot remove dot count it will tell you directly Okay, so if I want to add a unit in our have units dot add underscore unit one, then this unit one will be added to the first slot of my list that you see right here, this part here into slot number zero. So along your program running, you can add many unit objects. into the list.

Do you get it? At the same time, you can remove as well. Remove as you like.

So this is why list is dynamic. Do you get what I mean? Understand? Clear?

Good. So I hope that this one makes sense to you when I explain further. Okay.

No, it will automatically grow on the spot. It will allocate the memory address for it. No, it will be continuous readjust. Yes.

So everything set in a list will be next to each other. All right. The memory address will always be plus one, plus one, plus one, plus one next to each other.

Okay. So you have that. Now, back to here.

Okay, right now for this. Okay, now, can I have you to code this out for me? Unit, unit class.

All right, now I give you two options. First, you code it using your laptop. Second, you write it down. Third one, you imagine.

a student can imagine the quote like, oh, this is, I know I'm all like this. So you can use imagine also, but don't imagine something else, okay? Imagine this question here. So create this unit class, then I will share the answer with you.

Then you match, see whether is it the same or not. Is that possible? Yes?

Try, huh? Unit first. Now, let's see the answer for unit class.

Can you see from the back? You have a class unit. You have a string code, string name, and a Boolean available, right? You have...

a pass by value constructor, you get it correct. Okay, you will have a property for available. Okay, and you will have a pre unit detail methods to print the unit details out, you manage to get this.

yes huh so is it the same as what you imagine okay all right let's move on to the next one course course have a name id and at least units units okay this three first how do we write it in the code here okay now first of all all right first of all in order to use list, you need to add the right packages onto it, or you need to include the library into it. So the library that you're going to use here will be using system dot collections dot generic. This is the first thing.

Okay, any classes that involve the use of list LST, you will need to add using system dot collection dot generic semicolon. Clear the first step. Okay, if this class is for unit test, what should you use? And you need dot framework, you see that, okay, for systems or direction, collections dot generate the first thing, second thing, create a car course, okay, three field private string underscore name, private int underscore ID.

And the third one is private. The type is a list unit. The name is a underscore unit. Is it clear? i will make the code available in canvas okay but you can try you can try to type it in right now of course that's the best case scenario but if you cannot follow don't cry at the back there even you cry also cannot see yeah so don't cry don't get upset at the back there right but make sure that you go back when you open this set of code you know what does it mean okay yeah so three field here now The next thing is the constructor.

So you have a public course, right? It receives two parameters here, name and ID, right? Initialize the name accordingly. Initialize the ID accordingly.

okay the third field is a leaf all right which is a unit so what you are supposed to do is to tell the compiler to build the list to reserve the space for the leaf by putting underscore units equals to new list unit bracket i mean the list unit here is the type and calling the constructor for the list, which is in the library using system.collections.generate. You got what I mean? You will have underscore units equals to new list unit bracket. Every list must be initialized. This is initialization.

Now I ask you, does this line put any units inside? Yes or no? No, nothing. It is just trying to tell a compiler that if you want to build a course object, make sure you assign properly the name, the ID, and the next one, reserve a space for a list of units.

But there are nothing. inside the list of units yet get it okay now next part add unit you will have a public void add unit that will receive a unit object as parameter okay will receive a unit object as parameter so what you're supposed to do for this add unit is to add this unit object into the list of unit. So what you're required to do is underscore unit dot add. So this app is a method within the collection system, the collections dot framework library. So when you dot add, you will be able to add whatever you need object that you throw in here, it will be added to the list.

Does it make sense? Understand, no? Understand is very important, no?

I always say go back home. You look at the code, no one is going to whisper next to your ears. Who is going to whisper? You yourself, all right?

If you use a memorized way, right, when I change the question, immediately you don't know how to answer. If you try to memorize it, okay? You have the next method, remove. Unit what is this remove going to do public void? remove unit receive a unit object and it is going to ask the leaf dot Remove the unit it will remove it so simple right?

It's just so simple get it the object, it will, it will receive an entire object, it will remove best on the object. All right, it will do it for you. It will do it for you. That's a good question.

Okay, let's go I'll show you how I did it in the main, right in the main program. No, in the unit test was right in the unit test was how do I test it out. So this is remove.

sorry if it is not inside it won't remove anything yeah it won't return it wouldn't it wouldn't remove anything all right so this number will still be the same okay the next one that we are having is the num of unit this is this okay this num of unit method is going to return an integer. So you will have a public int num of unit. Okay, what is this num of unit going to do it will return the number of unit object in the list. Okay, how many unit object I have in the list.

So this particular method here will return the list which is underscore units dot count. Count is a special property that will return you the length of the list. Okay?

So we have.add,.remove,.count here. Okay? Can you tell me why is it that I need to have a return and the one on top no return?

Why? Because... Because in the design, the return data type is int.

So when you see this method, numOfUnit, it is an int, meaning that at the end of this method, you have to return an int, right? But you look at the method above the design, it is a void, void. do i need to return anything at the end of this function no get it yeah my eyes keep on looking at the student at the back are you guys doing okay yes okay good now display So this method here, display same thing, no return type. So it's a void. So when I see a void, you see the method here, there are no returns.

You see that. So I'm going to print out my course name, my course ID, and then this one is the design, right. And then for this particular list here, it is a list of unit right. So when it is a list of unit, I will need to look through every object in the list and ask that object to print details.

So you will have for each unit in units. Okay, how do you interpret that? For every unit object in units list, what are you going to do is ask the unit to print.

the unit details. Because back in your unit class, you already have a method called print unit details, whereby you console dot write line the bicycle, you console dot write line the unit code unit name and unit available availability. So over in your course class here, you just have to look through every of the unit object in the list.

Okay, as each of the unit object to print out. the unit details. Then it will print out the code, the name and availability.

Get it? Clear? I'm showing you some quick glance and at the same time I'm going through every line of the codes with you here so that you know that even you haven't watched through my lecture, you haven't watched through my lab demo, but you roughly have an idea that these are all the things that I have to know by the end of this week. If you already watched through my lecture, you already completed my lab demo, that means right now is a confirmation on whether you understand it correctly or not.

Any questions? No? Let's move on to the unit test.

In order to do unit test, you need to add the right packages into your project. I'm not going to demo how to add the packages because I already do that, right many, many times. So in order to write a unit test, okay, you will need to include the right end unit library.

Okay, make sure you level your test class with the right tagging test fixture. Okay, so over here, I want to create two unit tests. One is to test whether I can add successfully. Another is to test whether I can remove successfully or not. Okay?

So whenever we want to create a unit test, three steps. Setup, execute, check. Alright? Setup the object that you want to test. Ask the object to do something.

Check the result. Okay? So in order to test whether it can be added successfully, I need to setup. two objects here. One is for course, one is for unit.

Does that make sense? I create a new course, I create a new unit using the constructor that I have built. Okay, let me see, I can enlarge it. Yeah, I can. Okay, right.

So after I already set up, I execute. What is the method that I want to test? unit.

So I ask my course, course1.addUnit, throw the unit1 object as a parameter, okay? So you throw this unit1 object as a parameter here to the addUnit method, agree? So what is your addUnit method going to do?

Grab that object and add that object. into the lead underscore unit. All right.

Okay, so after you already added it into course one, then you check, what is the thing that you want to check course one dot num of unit, right, I want to check the number of unit inside course one object, is it equal to one doesn't make sense to you. This one, if I add one unit into my course, then the number of units for that cost is one, right? So that's why I put assert.arequal cost1.numOfUnit, right?

When you call the numOfUnit, this particular method here, it will return you the length of the list, which is the underscore units.count. Then you will have the value of one. Do you agree?

Yes? Now, if I want to test remove, can you imagine right now how should I write that to test the remove? Setup, I will setup my course object and my unit object.

Agree? Then execute, what should I do? Can I immediately remove?

You need to add first. Correct. Most probably, you want to add two units. or add one unit and then remove that unit. And when you check the number of units, it should be equivalent to zero because you didn't add anything, let's say.

If you add two, remove one, it will return to one. This is how you imagine first before you call it out. You get what I mean, right?

So over here, the test remove will be something like this. So you have a method test remove unit with the test tagging. Sorry, with the test tagging.

Right. So what will be your remove doing? Create a course, create two units, set up first. Okay, set up first.

Then add the unit into the course, add the second unit into the course. And then I check. Whether the number of units is 2, okay? Then, I remove 1. Remove unit 1. Do you see that?

Then, I check again. The remover should give me 1 at the end here. Do you understand what I'm trying to tell you? Alright? So, can I add 3?

and then I remove one and I check that is two. Yes. So this one you lay out because you are the developer you test it yourself.

As long as you don't add three, you remove one it becomes three. That's mean it's not removing at all something wrong with your codes. Do you understand what I'm trying to tell you?

Right? Does it make sense? Yes. Okay.

Now, let's look at the main program. I create a course object, I create a unit object, I add the unit into the course, temp course. Okay, I create another unit, I add the unit into temp course. Okay, so when I ask temp course dot display, what will be displaying? So the temp course will go to the display, which is the course will go to the display.

print out the course name, the course ID, right? So it will print out the course name is programming course, the ID is 9001. Okay, so after it print out the course name and course ID, the next thing that it will print out will be looping through the unit's list, and ask the unit to print the unit detail. So in this case here, it will look through the two unit object that has been added in which is cpp111 and cs125 so it will look through these two units and print out the detail do you understand all right so what you are doing right now right it's not only one class whenever i ask the course to display the course will display its own detail then it will ask the unit to display there are some connections with the other class to display to print out the unit detail is it clear right let me run it for you you should be able to see the detail been printed out for you here. Horse ID, right?

And the detail. Do you hear what I mean? Are you guys with me? Yes, huh?

Alright, so let's look at the code following down. Actually, I add and then I display, I remove and then I display. So what is that I'm trying to show you here is you can see from the outcome, as first got two units, but I remove 111. When I remove and I ask it to display 111, only one part here, the units here, this part, at first, I add to remove one, if we're not only one, understand.

Any questions? No questions? The student at the back?

Got a lot of drumming going at the back there. Student at the back, are you okay? Yes? No question at all? Clear?

Wow, that is so good. Serious? That means everyone will pass. Sorry?

Oh, okay. Oh, yeah. Yeah. Hopefully, yeah.

All right. Do you keep up with the pace of the lecture and the lab? I saw this semester is a little bit good, but I'm not sure whether am I the one that is happy myself. Because when I look at the submission, right, I think 70% have submitted.

my three and seven seems like that all right now there's a few thing that you need to take not now when you send an email to me or you drop me a team messages to ask me to look at whether you do it correctly or not what i'm looking at is whether your code is correct or not this is one thing uh but what are the things that you're supposed to submit that one you have to check yourself can you If you look at every part of the assessment criteria, right, it will say you have to submit your entire quotes, right? Sometimes it will say you have to submit your screenshot, okay? So that screenshot that has been mentioned content marks, content marks, right? So make sure that you review back your submission. If the assessment criteria asks you to include the screenshot, please include the screenshot accordingly.

Let's say you say include a screenshot that your main program is running. crop this out, save it as images. And if we say include a screenshot of unit has successfully so run the unit test right now, you should screenshot this, can you only screenshot this don't screenshot the entire you know, whatever folder here you also have. right your game's name all those things all inside there can you please don't do so can you maximize it and then screenshot this part again all right clear okay where is my attendance please yeah yeah good good good okay keep it let on you give me back so that's all what i'm going to cover with you today okay so you have no questions okay Now, if you have no questions, you can go.

All right? But you have questions, please step back. Okay? Step back. All right?

So I'll see you guys in the lab, yeah?