1 00:00:00,540 --> 00:00:02,670 ‫Welcome back to the second link demo. 2 00:00:02,670 --> 00:00:07,860 ‫In this demo we are going to prepare a bunch of stuff which we will need later on. 3 00:00:07,860 --> 00:00:13,890 ‫So first of all, we are going to create two additional classes and then actually third one which will 4 00:00:13,890 --> 00:00:15,120 ‫handle those two classes. 5 00:00:15,120 --> 00:00:20,880 ‫So those two classes that we are going to create, they should be used to create objects of those classes 6 00:00:20,880 --> 00:00:24,810 ‫and they are using universities and students. 7 00:00:24,810 --> 00:00:27,300 ‫So let's create a new class in here. 8 00:00:27,300 --> 00:00:31,290 ‫And yes, I know you should create classes on the right hand side. 9 00:00:31,290 --> 00:00:37,080 ‫Well, you should create specific files for every single class, but I'm going to create it in here 10 00:00:37,080 --> 00:00:43,260 ‫in the same file in this program, CSS file, because it's easier for you to follow along. 11 00:00:43,260 --> 00:00:45,780 ‫But otherwise you should always go like this. 12 00:00:45,780 --> 00:00:49,890 ‫Create new and then class, and then you should go ahead. 13 00:00:49,890 --> 00:00:54,360 ‫All right, so add class and this one will be university. 14 00:00:54,360 --> 00:01:00,630 ‫So every university has certain information about itself. 15 00:01:00,630 --> 00:01:02,610 ‫So what should a university have? 16 00:01:02,610 --> 00:01:05,670 ‫Well, let's start with an ID. 17 00:01:05,700 --> 00:01:14,940 ‫So I'm going to say it has an ID and this is a get and set property, a very basic property. 18 00:01:15,360 --> 00:01:22,890 ‫Then I create another property and this time like this, it's going to be a string time called name. 19 00:01:22,890 --> 00:01:26,730 ‫So every university has an ID and a name, nothing too fancy. 20 00:01:26,730 --> 00:01:27,210 ‫Right? 21 00:01:27,210 --> 00:01:31,440 ‫And then the only thing that we have to do in here is just print something. 22 00:01:31,440 --> 00:01:37,950 ‫So we're going to create a method in here which is gonna be called print, and it's going to print out 23 00:01:37,950 --> 00:01:41,160 ‫details, or we could call it show info or something like that. 24 00:01:41,430 --> 00:01:56,280 ‫The only thing it's going to do is write something like University zero with ID one and zero will be 25 00:01:56,280 --> 00:01:59,400 ‫the name and one will be the ID. 26 00:02:01,260 --> 00:02:03,780 ‫All right, so that's our university class. 27 00:02:04,800 --> 00:02:07,260 ‫And now let's create a class for students. 28 00:02:07,260 --> 00:02:10,800 ‫So class student. 29 00:02:10,800 --> 00:02:13,590 ‫So every university has students, right? 30 00:02:13,680 --> 00:02:29,340 ‫And we want you go ahead and have an ID for the students as well and ID get and set then a string called 31 00:02:29,340 --> 00:02:29,910 ‫name. 32 00:02:29,910 --> 00:02:39,810 ‫So every student has a name cut and set and then actually let's do it with prop double tap string and 33 00:02:39,810 --> 00:02:42,270 ‫every student has a gender. 34 00:02:43,170 --> 00:02:46,110 ‫And then finally we add one more property. 35 00:02:46,110 --> 00:02:49,200 ‫So prop and this time it's going to be the age. 36 00:02:49,200 --> 00:02:51,480 ‫So every student has a specific age. 37 00:02:51,960 --> 00:02:58,620 ‫And then here there is one important thing because every student has a foreign key, because if he's 38 00:02:58,620 --> 00:03:02,100 ‫not at the university, he's not a student. 39 00:03:02,100 --> 00:03:03,240 ‫So let's assume that. 40 00:03:03,870 --> 00:03:06,480 ‫So we need to have a foreign key. 41 00:03:06,600 --> 00:03:16,170 ‫Foreign key and that will be our public int university ID. 42 00:03:16,230 --> 00:03:20,730 ‫So a student belongs to a specific university ID. 43 00:03:21,780 --> 00:03:22,350 ‫All right. 44 00:03:22,650 --> 00:03:26,010 ‫And we finally also just print something onto the console. 45 00:03:26,010 --> 00:03:31,950 ‫So public void print and it's just going to print something like. 46 00:03:33,150 --> 00:03:36,780 ‫CW Double tap student 47 00:03:39,420 --> 00:04:01,890 ‫zero with ID one, gender two and age three from university with the ID four. 48 00:04:04,110 --> 00:04:06,570 ‫And now of course need to use all of those properties. 49 00:04:06,570 --> 00:04:15,870 ‫So it's going to be name ID, gender, age and university ID. 50 00:04:17,670 --> 00:04:22,590 ‫And as this is a little long, I'm going to put it on the second line like that. 51 00:04:22,890 --> 00:04:27,750 ‫So this is going to be the print statement of the student class. 52 00:04:27,870 --> 00:04:36,660 ‫Now, in order to manage students and universities in the linkway, we will create another class. 53 00:04:36,660 --> 00:04:40,440 ‫And this additional class is going to be our university manager. 54 00:04:40,440 --> 00:04:47,280 ‫So it's going to handle universities, it's going to add members to the university, so students to 55 00:04:47,280 --> 00:04:48,420 ‫the university. 56 00:04:48,420 --> 00:04:54,900 ‫Then it's going to show us all the male students, all the female students and those kind of things. 57 00:04:54,900 --> 00:04:59,760 ‫So let's create a new class for that, and I'm going to call it Class Uni. 58 00:05:00,010 --> 00:05:02,170 ‫Our city manager. 59 00:05:02,800 --> 00:05:06,150 ‫And then here I want to have lists to work with. 60 00:05:06,160 --> 00:05:14,470 ‫So first of all, I have a list of university, so of our university type that we had and I'm going 61 00:05:14,470 --> 00:05:16,300 ‫to call that university. 62 00:05:17,290 --> 00:05:23,890 ‫And then another list, public list called student, which is going to be our students. 63 00:05:24,610 --> 00:05:28,450 ‫So this list is full of students, this list is full of universities. 64 00:05:28,630 --> 00:05:35,350 ‫And now in a constructor, we will initialize those two lists and we will add values to them. 65 00:05:35,500 --> 00:05:43,210 ‫So let's go ahead and create a constructor public university manager like that. 66 00:05:44,380 --> 00:05:46,180 ‫Now, that's our constructor, right? 67 00:05:47,080 --> 00:05:48,360 ‫Constructor. 68 00:05:48,370 --> 00:05:54,130 ‫And in here, I want to go ahead and initialize my university. 69 00:05:54,940 --> 00:06:00,130 ‫So it's going to be a new list of university 70 00:06:02,590 --> 00:06:08,770 ‫and my students, which will be a new list of student. 71 00:06:12,070 --> 00:06:14,470 ‫And now we can go ahead and add values to them. 72 00:06:14,470 --> 00:06:17,200 ‫And I'm not going to type everything manually. 73 00:06:17,200 --> 00:06:20,670 ‫I'm just going to copy and paste from the list that I've prepared. 74 00:06:20,680 --> 00:06:23,290 ‫So let's assume we have two universities. 75 00:06:23,560 --> 00:06:26,230 ‫One is Yale, and the other one is Beijing Tech. 76 00:06:26,800 --> 00:06:31,300 ‫And then we have let's some students here, which is Carla, who's female. 77 00:06:31,300 --> 00:06:32,140 ‫She's 17. 78 00:06:32,140 --> 00:06:34,960 ‫Then there's Toni, he's male, he's 21. 79 00:06:35,050 --> 00:06:40,570 ‫And those two, they are at Yale and then the other university. 80 00:06:40,570 --> 00:06:47,290 ‫So at Beijing Tech, we have Lila, which is female, then James, who's transgender, and then we have 81 00:06:47,290 --> 00:06:48,730 ‫Linda, who's female. 82 00:06:49,090 --> 00:06:49,450 ‫All right. 83 00:06:49,450 --> 00:06:54,190 ‫So we have three different here, three different genders. 84 00:06:55,270 --> 00:06:55,690 ‫All right. 85 00:06:55,690 --> 00:06:59,470 ‫So this is our university manager constructor so far. 86 00:06:59,470 --> 00:07:05,890 ‫And now we can go ahead and add some methods which will actually do some link things because we haven't 87 00:07:05,890 --> 00:07:07,900 ‫used link in this video yet. 88 00:07:07,900 --> 00:07:09,370 ‫So let's go ahead and do that. 89 00:07:09,520 --> 00:07:10,660 ‫Let's create. 90 00:07:11,980 --> 00:07:17,050 ‫A method which will give us all the male students. 91 00:07:18,760 --> 00:07:20,210 ‫So let's create that. 92 00:07:20,230 --> 00:07:30,700 ‫And here I'm going to use I enumerable so a list of students and I'm going to call it male students. 93 00:07:31,360 --> 00:07:34,000 ‫And now we use the same thing that we did in the last video. 94 00:07:34,000 --> 00:07:48,250 ‫So from student in students where student gender is equal to male and finally select student. 95 00:07:48,430 --> 00:07:48,790 ‫All right. 96 00:07:48,790 --> 00:07:51,420 ‫So that's how we create this list. 97 00:07:51,430 --> 00:07:53,010 ‫We have seen it in the last video. 98 00:07:53,020 --> 00:07:55,870 ‫We check out a specific list. 99 00:07:55,870 --> 00:08:01,300 ‫In this case, it's a actually list because so far we have seen that with a raise. 100 00:08:01,300 --> 00:08:03,130 ‫But you can do that with lists as well. 101 00:08:03,130 --> 00:08:04,450 ‫So that's pretty cool. 102 00:08:04,630 --> 00:08:10,420 ‫As you can see, collections, generic list and we can do that with this link approach here as well. 103 00:08:11,410 --> 00:08:14,740 ‫So now let's print that on to the console. 104 00:08:14,830 --> 00:08:24,700 ‫See, W is going to be male students and then finally, let's give us all the students. 105 00:08:24,700 --> 00:08:35,980 ‫So we're going to use a for each loop here for each student, which is student in male students, because 106 00:08:35,980 --> 00:08:40,120 ‫as we know, our male students are of type student. 107 00:08:40,210 --> 00:08:46,300 ‫So now we can go ahead and call the student dot print method. 108 00:08:47,080 --> 00:08:52,720 ‫All right, now let's go ahead and use this method, because so far we have only prepared and type code 109 00:08:52,720 --> 00:08:57,360 ‫and type code, and now it's time to finally run the code and see what's going on. 110 00:08:57,370 --> 00:09:01,480 ‫So let's go ahead and create a university manager object. 111 00:09:01,810 --> 00:09:09,520 ‫Let's call it, um, and let's initialize it straightaway, which is a university manager like that. 112 00:09:09,520 --> 00:09:16,240 ‫And now I can go ahead and use, um, dot male students. 113 00:09:16,510 --> 00:09:22,960 ‫So this method here and finally let's also write onto the console. 114 00:09:22,960 --> 00:09:29,170 ‫So console dot read key so that our program doesn't just shut down. 115 00:09:29,350 --> 00:09:32,020 ‫All right, so let's run it. 116 00:09:32,470 --> 00:09:38,770 ‫And we see here male students well, we have student Toni with the idea of one gender male age 21 from 117 00:09:38,770 --> 00:09:41,650 ‫university with the ID one. 118 00:09:42,130 --> 00:09:43,780 ‫All right, so let's check it out. 119 00:09:44,320 --> 00:09:51,970 ‫We have this one male student here, so let's copy and paste the male student just to check if there 120 00:09:52,000 --> 00:09:52,810 ‫can be two. 121 00:09:52,810 --> 00:09:55,900 ‫So this one will be frank. 122 00:09:55,900 --> 00:10:01,600 ‫And Frank is male, but he's 22 years old and he's at the second university as well. 123 00:10:01,600 --> 00:10:04,600 ‫So everyone is at Beijing University as it seems. 124 00:10:04,600 --> 00:10:06,220 ‫So let's run the code again. 125 00:10:06,880 --> 00:10:10,360 ‫And then we are we see both rows, so we see Frank and we see Tony. 126 00:10:10,630 --> 00:10:14,170 ‫So Frank is from University one and Tony? 127 00:10:14,170 --> 00:10:16,450 ‫Well, actually, Tony is from one and Frank is from two. 128 00:10:16,780 --> 00:10:17,350 ‫All right. 129 00:10:17,350 --> 00:10:20,230 ‫So now you see this method worked fine. 130 00:10:20,230 --> 00:10:24,010 ‫Now please go ahead and create a method that does the same thing. 131 00:10:24,010 --> 00:10:25,300 ‫But for women. 132 00:10:25,300 --> 00:10:30,640 ‫So we're just going to print out all the female students from the different universities. 133 00:10:33,630 --> 00:10:34,020 ‫All right. 134 00:10:34,020 --> 00:10:35,100 ‫I hope you tried it. 135 00:10:35,100 --> 00:10:37,050 ‫So I'm going to type it this time. 136 00:10:37,080 --> 00:10:38,270 ‫Public void. 137 00:10:38,280 --> 00:10:48,090 ‫Female Student And I need an I enumerable again, which will be of type student. 138 00:10:49,530 --> 00:10:55,260 ‫So a list of students which is going to be a female student's list. 139 00:10:55,260 --> 00:10:59,640 ‫And I want to check from all the students. 140 00:11:02,070 --> 00:11:03,120 ‫In students. 141 00:11:03,120 --> 00:11:07,260 ‫So this is, as I said before, each loop here basically. 142 00:11:07,260 --> 00:11:18,090 ‫And we want to check all the students where the gender is female and we want to select those students 143 00:11:18,090 --> 00:11:22,590 ‫and put them into our female students. 144 00:11:23,160 --> 00:11:33,180 ‫I enumerable Now we can write that on the console, so w and female students 145 00:11:35,910 --> 00:11:48,510 ‫and then we use a for each loop like that it's going to use student called student and the collection 146 00:11:48,510 --> 00:11:51,390 ‫called Female Students. 147 00:11:52,260 --> 00:11:55,380 ‫And now in here we're just going to use student dot print. 148 00:11:57,420 --> 00:11:59,490 ‫So now let's check out the female students. 149 00:11:59,490 --> 00:12:04,800 ‫So u m dot female students method. 150 00:12:05,130 --> 00:12:07,350 ‫And I know that this name is not perfect. 151 00:12:07,350 --> 00:12:13,980 ‫It could be something like show female students or filter by female students or filter by male students. 152 00:12:13,980 --> 00:12:15,780 ‫But I'll just keep it simple here. 153 00:12:16,530 --> 00:12:24,720 ‫And we are female students Carla, Layla and Linda with ad1, three and five, age 17, 19 and 22. 154 00:12:24,720 --> 00:12:27,540 ‫And they are different universities, as you can see here. 155 00:12:28,260 --> 00:12:28,680 ‫All right. 156 00:12:28,680 --> 00:12:33,840 ‫So now you have seen how you can create a bigger list in this case. 157 00:12:33,840 --> 00:12:38,790 ‫We are just using a list here with elements that we have added. 158 00:12:38,790 --> 00:12:43,830 ‫So you have seen how you can do that with arrays, how we can use link. 159 00:12:43,830 --> 00:12:50,340 ‫So this statement here with the race and also with lists and you can use the same thing with enumerable 160 00:12:50,370 --> 00:12:53,340 ‫as with well generally list types, right? 161 00:12:53,610 --> 00:12:58,230 ‫And also of course with tables and with XML. 162 00:12:58,230 --> 00:13:00,540 ‫And that's something that we will see later on. 163 00:13:00,540 --> 00:13:07,260 ‫So let's go ahead to the next video where we will extend our class here. 164 00:13:07,260 --> 00:13:13,740 ‫So our university manager class, which will well, show us some more information because so far we 165 00:13:13,740 --> 00:13:16,050 ‫only see students, male and female. 166 00:13:16,050 --> 00:13:22,770 ‫But what if we want to filter it by different information or if you want to sort it, stuff like that, 167 00:13:22,980 --> 00:13:25,140 ‫that's something that we will cover in the next video. 168 00:13:25,140 --> 00:13:27,360 ‫So see you in the next video.