‫Welcome back to the second link demo.
‫In this demo we are going to prepare a bunch of stuff which we will need later on.
‫So first of all, we are going to create two additional classes and then actually third one which will
‫handle those two classes.
‫So those two classes that we are going to create, they should be used to create objects of those classes
‫and they are using universities and students.
‫So let's create a new class in here.
‫And yes, I know you should create classes on the right hand side.
‫Well, you should create specific files for every single class, but I'm going to create it in here
‫in the same file in this program, CSS file, because it's easier for you to follow along.
‫But otherwise you should always go like this.
‫Create new and then class, and then you should go ahead.
‫All right, so add class and this one will be university.
‫So every university has certain information about itself.
‫So what should a university have?
‫Well, let's start with an ID.
‫So I'm going to say it has an ID and this is a get and set property, a very basic property.
‫Then I create another property and this time like this, it's going to be a string time called name.
‫So every university has an ID and a name, nothing too fancy.
‫Right?
‫And then the only thing that we have to do in here is just print something.
‫So we're going to create a method in here which is gonna be called print, and it's going to print out
‫details, or we could call it show info or something like that.
‫The only thing it's going to do is write something like University zero with ID one and zero will be
‫the name and one will be the ID.
‫All right, so that's our university class.
‫And now let's create a class for students.
‫So class student.
‫So every university has students, right?
‫And we want you go ahead and have an ID for the students as well and ID get and set then a string called
‫name.
‫So every student has a name cut and set and then actually let's do it with prop double tap string and
‫every student has a gender.
‫And then finally we add one more property.
‫So prop and this time it's going to be the age.
‫So every student has a specific age.
‫And then here there is one important thing because every student has a foreign key, because if he's
‫not at the university, he's not a student.
‫So let's assume that.
‫So we need to have a foreign key.
‫Foreign key and that will be our public int university ID.
‫So a student belongs to a specific university ID.
‫All right.
‫And we finally also just print something onto the console.
‫So public void print and it's just going to print something like.
‫CW Double tap student
‫zero with ID one, gender two and age three from university with the ID four.
‫And now of course need to use all of those properties.
‫So it's going to be name ID, gender, age and university ID.
‫And as this is a little long, I'm going to put it on the second line like that.
‫So this is going to be the print statement of the student class.
‫Now, in order to manage students and universities in the linkway, we will create another class.
‫And this additional class is going to be our university manager.
‫So it's going to handle universities, it's going to add members to the university, so students to
‫the university.
‫Then it's going to show us all the male students, all the female students and those kind of things.
‫So let's create a new class for that, and I'm going to call it Class Uni.
‫Our city manager.
‫And then here I want to have lists to work with.
‫So first of all, I have a list of university, so of our university type that we had and I'm going
‫to call that university.
‫And then another list, public list called student, which is going to be our students.
‫So this list is full of students, this list is full of universities.
‫And now in a constructor, we will initialize those two lists and we will add values to them.
‫So let's go ahead and create a constructor public university manager like that.
‫Now, that's our constructor, right?
‫Constructor.
‫And in here, I want to go ahead and initialize my university.
‫So it's going to be a new list of university
‫and my students, which will be a new list of student.
‫And now we can go ahead and add values to them.
‫And I'm not going to type everything manually.
‫I'm just going to copy and paste from the list that I've prepared.
‫So let's assume we have two universities.
‫One is Yale, and the other one is Beijing Tech.
‫And then we have let's some students here, which is Carla, who's female.
‫She's 17.
‫Then there's Toni, he's male, he's 21.
‫And those two, they are at Yale and then the other university.
‫So at Beijing Tech, we have Lila, which is female, then James, who's transgender, and then we have
‫Linda, who's female.
‫All right.
‫So we have three different here, three different genders.
‫All right.
‫So this is our university manager constructor so far.
‫And now we can go ahead and add some methods which will actually do some link things because we haven't
‫used link in this video yet.
‫So let's go ahead and do that.
‫Let's create.
‫A method which will give us all the male students.
‫So let's create that.
‫And here I'm going to use I enumerable so a list of students and I'm going to call it male students.
‫And now we use the same thing that we did in the last video.
‫So from student in students where student gender is equal to male and finally select student.
‫All right.
‫So that's how we create this list.
‫We have seen it in the last video.
‫We check out a specific list.
‫In this case, it's a actually list because so far we have seen that with a raise.
‫But you can do that with lists as well.
‫So that's pretty cool.
‫As you can see, collections, generic list and we can do that with this link approach here as well.
‫So now let's print that on to the console.
‫See, W is going to be male students and then finally, let's give us all the students.
‫So we're going to use a for each loop here for each student, which is student in male students, because
‫as we know, our male students are of type student.
‫So now we can go ahead and call the student dot print method.
‫All right, now let's go ahead and use this method, because so far we have only prepared and type code
‫and type code, and now it's time to finally run the code and see what's going on.
‫So let's go ahead and create a university manager object.
‫Let's call it, um, and let's initialize it straightaway, which is a university manager like that.
‫And now I can go ahead and use, um, dot male students.
‫So this method here and finally let's also write onto the console.
‫So console dot read key so that our program doesn't just shut down.
‫All right, so let's run it.
‫And we see here male students well, we have student Toni with the idea of one gender male age 21 from
‫university with the ID one.
‫All right, so let's check it out.
‫We have this one male student here, so let's copy and paste the male student just to check if there
‫can be two.
‫So this one will be frank.
‫And Frank is male, but he's 22 years old and he's at the second university as well.
‫So everyone is at Beijing University as it seems.
‫So let's run the code again.
‫And then we are we see both rows, so we see Frank and we see Tony.
‫So Frank is from University one and Tony?
‫Well, actually, Tony is from one and Frank is from two.
‫All right.
‫So now you see this method worked fine.
‫Now please go ahead and create a method that does the same thing.
‫But for women.
‫So we're just going to print out all the female students from the different universities.
‫All right.
‫I hope you tried it.
‫So I'm going to type it this time.
‫Public void.
‫Female Student And I need an I enumerable again, which will be of type student.
‫So a list of students which is going to be a female student's list.
‫And I want to check from all the students.
‫In students.
‫So this is, as I said before, each loop here basically.
‫And we want to check all the students where the gender is female and we want to select those students
‫and put them into our female students.
‫I enumerable Now we can write that on the console, so w and female students
‫and then we use a for each loop like that it's going to use student called student and the collection
‫called Female Students.
‫And now in here we're just going to use student dot print.
‫So now let's check out the female students.
‫So u m dot female students method.
‫And I know that this name is not perfect.
‫It could be something like show female students or filter by female students or filter by male students.
‫But I'll just keep it simple here.
‫And we are female students Carla, Layla and Linda with ad1, three and five, age 17, 19 and 22.
‫And they are different universities, as you can see here.
‫All right.
‫So now you have seen how you can create a bigger list in this case.
‫We are just using a list here with elements that we have added.
‫So you have seen how you can do that with arrays, how we can use link.
‫So this statement here with the race and also with lists and you can use the same thing with enumerable
‫as with well generally list types, right?
‫And also of course with tables and with XML.
‫And that's something that we will see later on.
‫So let's go ahead to the next video where we will extend our class here.
‫So our university manager class, which will well, show us some more information because so far we
‫only see students, male and female.
‫But what if we want to filter it by different information or if you want to sort it, stuff like that,
‫that's something that we will cover in the next video.
‫So see you in the next video.