WEBVTT

00:05.890 --> 00:11.860
Read the end of the section so we'll be doing the final part of the mini project that was started in

00:11.860 --> 00:19.150
the last section and this will be the last lecture that we will do practice in the next section.

00:19.150 --> 00:26.020
We'll have more of the library that we're going to use for the final game.

00:26.260 --> 00:29.530
So we're not really going to do much practice with that.

00:29.530 --> 00:32.730
We'll just use it for the final game instead.

00:33.560 --> 00:42.920
So the final part of this Me project says Replace the C strings with C++ strings.

00:43.220 --> 00:50.580
Use a vector instead of dynamic memory and use a text file instead of a binary file.

00:50.720 --> 00:54.800
So we'll get to the rest of this later.

00:54.800 --> 01:02.080
So first what I really want to do is when when approaching a problem like this where you do kind of

01:02.080 --> 01:06.210
a revision of what you've done before.

01:06.520 --> 01:13.810
Really what you want to do is to get to parity with the last version.

01:13.870 --> 01:22.300
So you want to update the strings with the C++ strings and a vector and the text file and just get everything

01:22.300 --> 01:24.190
working like it was before.

01:24.360 --> 01:35.480
OK so we'll start with changing the strings or the C strings to use strings so will need an set of string.

01:35.480 --> 01:43.970
Or any CPP just regular strings of strings and are going to also include the vector

01:47.170 --> 01:56.380
K and the next thing we'll do is we'll change the data to reflect the changes that we need.

01:56.380 --> 02:00.440
So will do a string for a first name

02:03.160 --> 02:08.550
string for the last.

02:09.400 --> 02:14.530
And instead of having the memory like we have here.

02:14.590 --> 02:27.330
You will just use a vector so that this will do a vector of contacts.

02:27.530 --> 02:35.510
Contact us and notice that it's not like an old pointer of contacts just contacts because vector itself

02:35.510 --> 02:38.690
will do all the dynamic memory for us.

02:38.820 --> 02:46.950
OK so now that we've kind of changed the data and we should also change this as well.

02:47.110 --> 02:47.980
TXT file

02:52.000 --> 02:58.080
now that you've done these kind of data changes we'll have to update our code to reflect the change.

02:58.130 --> 03:07.020
So we're going to go through the whole thing and then just make whatever changes are necessary.

03:07.580 --> 03:15.170
So here we don't need any of this in the main because this kind of had to do with the dynamic memory

03:15.170 --> 03:15.860
portion of it.

03:15.860 --> 03:20.300
So this kind of remove it.

03:20.940 --> 03:27.570
We don't need to delete it after because the vector will actually take care of that for us

03:30.150 --> 03:39.910
and that's it for this for now although you'll see why.

03:40.180 --> 03:46.160
Oh well if we don't if we can't read the file We're just not going to bother.

03:46.260 --> 03:58.860
OK so we're was going to load the contacts so they and in fact we won't need to create the file anymore

03:58.920 --> 04:02.460
because again if we don't have the file then that's fine.

04:06.510 --> 04:12.670
So now we will.

04:13.110 --> 04:15.430
We don't need this function anymore.

04:17.950 --> 04:23.970
Take away and all of this is needs changing.

04:24.010 --> 04:26.140
So it's not binary anymore.

04:28.990 --> 04:38.060
And let's just sort of remove all this and in a minute we will rewrite it.

04:39.740 --> 04:42.520
It will do the same for the save

04:48.230 --> 04:58.200
So we we don't need to resize the context at all because our vector for us so is this function entirely

04:59.470 --> 05:05.570
in for the display.

05:05.840 --> 05:12.320
You have to use the actual size function of the contact's vector.

05:12.720 --> 05:14.840
That's how many contacts we have now.

05:16.210 --> 05:27.280
And have these 0.10 contacts just contacts this.

05:27.630 --> 05:31.730
How will this play an option.

05:31.740 --> 05:39.650
We started with the resize but again we don't need to resize it because factor that for us we don't

05:39.650 --> 05:46.310
need to add 1 to the number of contacts anymore because again once we add it properly it will just kind

05:46.310 --> 05:48.050
of work.

05:48.060 --> 05:51.940
So how do we fix this.

05:51.960 --> 06:00.720
Right now it's getting the string as a C string but instead of that let's change this function to use

06:00.780 --> 06:03.600
as a C plus string.

06:04.150 --> 06:09.870
So when you have a new contact

06:14.440 --> 06:15.310
like so.

06:15.970 --> 06:18.050
And we're going to use it here.

06:18.070 --> 06:27.510
So we're going to change this to be our new content.

06:28.840 --> 06:32.140
And now we don't need this size anymore.

06:32.150 --> 06:33.080
It could be big.

06:33.100 --> 06:33.730
We want

06:37.300 --> 06:39.660
a new contact here.

06:43.170 --> 06:45.110
Like that.

06:46.050 --> 06:56.770
And similarly here we just get the new content and here will just add it to the context to be

07:03.900 --> 07:06.810
pushed back to do so just add it to the end.

07:07.930 --> 07:15.700
It doesn't really matter the order for now and now we need to change this get string function to use

07:16.740 --> 07:19.090
C++ strings and Cives Caesar.

07:19.250 --> 07:32.110
So in that file and we'll need the string library here in this and we just change this to be a string

07:33.040 --> 07:41.620
and we'll need to use stood colon colon because we're not going to put the line using namespace studio

07:41.670 --> 07:42.280
here.

07:42.430 --> 07:43.100
OK.

07:43.330 --> 07:49.610
So if you don't have the using names is SDD when you actually say the actual namespace and then call

07:49.650 --> 07:56.380
in Colon and then here will say string and we'll pass it by reference.

07:56.430 --> 07:58.760
Name it a string.

08:01.980 --> 08:05.900
And now we need to change the station as well.

08:07.350 --> 08:10.530
We scroll down to it here.

08:11.420 --> 08:12.930
This needs to be a string

08:16.010 --> 08:16.580
blustering

08:22.930 --> 08:27.920
and we could change some of the stuff so we don't need these two lines anymore.

08:28.390 --> 08:35.240
We just need to say see in string because CNH works with small strings just fine.

08:35.970 --> 08:50.050
And here we could just say string dot it's way that way and it's really all we need to do is function

08:51.710 --> 08:54.790
back.

08:55.140 --> 09:04.290
OK so we're creating new contact we're just populating that contacts first name last name and his phone

09:04.290 --> 09:09.520
number and then just pushing it back into our contacts vector.

09:10.690 --> 09:13.480
And saving it just like normal.

09:13.630 --> 09:21.580
So now that that's done let's start tackling the load contacts and save contex.

09:21.590 --> 09:23.480
Let's start with the Save contacts

09:26.440 --> 09:29.890
easier slightly easier.

09:29.890 --> 09:34.040
All you have to do is go through each each contact.

09:34.550 --> 09:38.160
For his last then contacts

09:40.340 --> 09:44.480
the dot contacts site.

09:44.770 --> 09:45.950
That's how many there are

09:50.020 --> 09:58.020
and we need to output those contacts to the file and we'll do that.

09:58.070 --> 10:08.240
And I was out with our file do that with the insertion operator and we'll see what contacts the contacts

10:08.790 --> 10:16.380
I adopt first name and we'll put a space between the names and the phone number as well.

10:17.270 --> 10:22.280
Contacts the contacts

10:24.760 --> 10:25.520
last name

10:31.960 --> 10:37.480
the contacts.

10:37.710 --> 10:38.000
It's

10:42.160 --> 10:46.450
like that.

10:46.790 --> 10:52.900
So this will actually print out to the file one on one contact essentially.

10:53.040 --> 10:57.340
So each line of the file will be one contact.

10:57.500 --> 10:57.960
OK.

10:58.730 --> 11:06.140
And now I only want to output new lines if

11:09.350 --> 11:14.510
if there are more contacts after me.

11:14.630 --> 11:18.460
So after the current one Ratsch the either one right.

11:18.550 --> 11:19.410
OK.

11:19.530 --> 11:27.090
So we'll say contacts size minus one.

11:27.120 --> 11:35.160
So as long as I is less than the last contact and the index of the last contact which is this right

11:35.160 --> 11:42.730
here then will output a new line.

11:42.750 --> 11:45.420
This is to make sure.

11:45.450 --> 11:55.670
So make sure that there is no new line.

11:56.020 --> 12:06.870
And file is what this is saying essentially and you may be wondering why don't we.

12:06.870 --> 12:08.520
Why do we care about that.

12:08.550 --> 12:15.630
Well sometimes the way we read in the way we'll be reading it in that will cause a problem if there

12:15.630 --> 12:15.910
is.

12:15.930 --> 12:19.950
So we're going to kind of make sure that doesn't happen.

12:20.110 --> 12:31.590
OK so now look at load contacts function and here will say we'll just get a new contract.

12:31.870 --> 12:32.730
This will be our

12:36.270 --> 12:39.540
the one that we store.

12:39.570 --> 12:42.930
Each line will read a contact and then we'll store it into this one.

12:43.060 --> 12:48.340
OK and we'll say while not in file.

12:51.000 --> 12:52.030
OK.

12:52.200 --> 12:58.020
And what this is is while we're not at the end of the file.

12:58.170 --> 13:06.930
So each file has kind of a marker at the very end of it which signifies that that's the end of the file.

13:07.260 --> 13:13.290
And this is all this is doing and saying wow the the current cursor of the file is not at the end of

13:13.290 --> 13:14.470
the file.

13:14.760 --> 13:18.300
That's what we're doing here say in file.

13:18.870 --> 13:29.610
So we'll read any whitespace first and then if if the file was empty let's say.

13:29.780 --> 13:38.010
So if we're at the end of the file already then we should just get out of the file OK.

13:38.260 --> 13:43.880
So this has to do with this kind of whitespace problem.

13:43.910 --> 13:51.410
It was always kind of a weird problem in textfiles as usual I don't really like to use them that much.

13:51.910 --> 13:56.640
So we'll just read the line contacts.

13:56.870 --> 14:01.100
It's and you contact

14:05.400 --> 14:06.120
first name

14:08.750 --> 14:11.120
you contact each

14:16.910 --> 14:20.290
last name and get the phone numbers.

14:20.300 --> 14:20.900
Wow.

14:26.240 --> 14:32.670
And again this extraction operator can read strings.

14:33.050 --> 14:35.960
It's overloaded to read strings so.

14:36.210 --> 14:37.370
And this will also

14:42.090 --> 14:45.610
this will also ignore whitespace.

14:45.780 --> 14:49.870
So these kind of white spaces that we put in here you'll just be ignored.

14:49.910 --> 14:53.420
So this will be fine.

14:53.450 --> 14:55.810
And then we just add it to the database.

15:06.710 --> 15:08.610
Using pushback.

15:11.610 --> 15:11.990
Dr.

15:16.610 --> 15:27.280
in it's I think it it's like I said before we don't really care if the file exists or not we'll just

15:27.390 --> 15:28.820
it will just be empty.

15:28.880 --> 15:29.420
Right.

15:32.230 --> 15:40.110
The vector to removing the file or the functions that need.

15:40.320 --> 15:43.670
And if we run this

15:47.020 --> 15:51.610
you'll see that you have no contacts in.

15:51.790 --> 15:52.330
I don't

15:57.330 --> 15:58.850
display that.

15:59.010 --> 16:00.180
So I one one

16:07.150 --> 16:08.130
display.

16:08.410 --> 16:17.060
So we have and quit and that's just rerun it and make sure that C properly display.

16:17.650 --> 16:20.320
So we have our two contacts.

16:21.400 --> 16:22.440
So that's good.

16:22.450 --> 16:27.130
So it's basically working as it did before.

16:27.520 --> 16:31.740
And if you want to see the file See

16:39.280 --> 16:45.380
here's the file that saved and it's in nice text that we can understand.

16:45.970 --> 16:52.250
So says Fred Flintstone on one line with the space just like how we save it

16:55.450 --> 17:00.810
is a first name last name first name last name in

17:07.280 --> 17:07.490
that

17:11.210 --> 17:12.020
phone.

17:13.520 --> 17:21.550
And noticed that we read it in the same way so read back in first name last name or number.

17:22.130 --> 17:27.760
So that kind of parity now with what we had before.

17:28.040 --> 17:31.330
Now let's add in the rest of what it said.

17:31.340 --> 17:39.240
So it says really a function that will remove a contact from the vector make this an option in the main

17:39.260 --> 17:40.930
that way.

17:41.150 --> 17:43.210
So let's do that.

17:43.250 --> 17:49.380
So we'll add any function says void.

17:49.530 --> 17:50.730
Remove option

17:53.310 --> 17:55.100
2 contacts divi

17:58.020 --> 18:02.360
reference.

18:06.730 --> 18:14.270
Add it to an.

18:14.610 --> 18:20.730
And we need to as I said here make this an option and make menus.

18:20.730 --> 18:23.830
You need to change the main menu here.

18:24.060 --> 18:25.990
Option user.

18:26.290 --> 18:35.660
And we'll add it right after AD contex say our eyes remove contact

18:39.320 --> 18:43.830
whine like that and add it here as well.

18:43.860 --> 18:46.390
Our right.

18:46.440 --> 18:51.630
It's a new option and it's three four options.

18:52.550 --> 18:54.190
And we have four options.

18:54.230 --> 19:03.280
And in this execute you need to change it so there is a new case to remove option.

19:11.400 --> 19:11.600
Number

19:17.000 --> 19:28.900
OK so let's let's just run this and see hopefully make steak so see that there is play add in or move

19:28.960 --> 19:30.350
straight to.

19:30.490 --> 19:31.970
Nothing happens yet.

19:32.080 --> 19:33.180
We have implemented it.

19:33.490 --> 19:34.850
So that's fine.

19:38.340 --> 19:44.330
So let's implement remove the Remove the options.

19:45.940 --> 19:47.710
Here we will.

19:47.710 --> 19:49.560
How will we do this.

19:49.620 --> 19:57.070
So how will the user know which one to remove.

19:57.200 --> 20:01.370
We could make them enter the first name and last name maybe.

20:01.400 --> 20:05.060
But what if they have the same name like John Smith.

20:05.060 --> 20:10.380
So we actually remove it by phone number so

20:12.980 --> 20:20.920
first we'll check to see if we have any contacts at all because if we don't then there's no point removed.

20:20.950 --> 20:21.170
Right

20:24.950 --> 20:28.980
Size like that.

20:29.080 --> 20:31.920
So it's greater than zero.

20:31.950 --> 20:32.470
Right.

20:33.500 --> 20:39.150
Or if we say less than or equal to zero we could say ouch.

20:39.370 --> 20:48.450
No contacts in the list.

20:49.110 --> 20:53.390
And would just return like that.

20:53.460 --> 20:57.020
So you could do a return with nothing right.

20:57.120 --> 20:59.780
If it's void.

21:00.180 --> 21:04.390
So this will just kind of exit the function.

21:04.440 --> 21:16.500
So if we do have contacts so if we do get to this point we should probably I guess input the phone number

21:18.220 --> 21:24.820
we could do it by could do it by first name my last name but again there might be the same last name

21:27.380 --> 21:29.310
but maybe that will be better.

21:29.310 --> 21:33.190
It could be a better option at least to see visually.

21:33.230 --> 21:34.600
So maybe that's what we'll do.

21:34.610 --> 21:45.220
So we'll say string and this also helps us with using strings more string first names and last name

21:47.170 --> 21:56.170
really what you want is some kind of ID for every for every contact and we you would actually remove

21:56.170 --> 21:58.020
it based off.

21:58.120 --> 21:59.490
But we're not going to do it here.

21:59.500 --> 22:08.440
So we'll actually get the first name and last name from the users say please enter first name

22:12.140 --> 22:14.380
in Pasadena hairspring

22:18.680 --> 22:42.520
first name it's right you get the last name.

22:42.700 --> 22:49.930
So now that we have the first name and last name we have to actually go through our vector and see if

22:50.050 --> 22:53.800
anyone matches up with that first name and last name.

22:53.800 --> 23:01.090
OK so we'll need some kind of boolean to know if we found it or not and we'll just kind of delete the

23:01.090 --> 23:07.470
first one we find so if there's duplicate say there's like two John Smiths Woods delete the first one

23:09.230 --> 23:14.560
and it's the index that we found it at.

23:14.610 --> 23:21.560
Found index will start at negative 1 because negative 1 will signify that we don't.

23:21.600 --> 23:23.220
You haven't found anything.

23:24.390 --> 23:33.250
It's only zero is less than the number of contacts in the database

23:36.770 --> 23:39.220
signs.

23:41.300 --> 23:42.140
So it's

23:45.340 --> 23:51.310
and we haven't found it.

23:51.390 --> 23:57.180
It's both conditions because if we do find it then we'll just kind of exit it.

23:57.640 --> 24:01.720
So if the current one that we're looking at

24:08.490 --> 24:10.200
is equal to the first name

24:13.650 --> 24:14.490
and

24:19.060 --> 24:20.620
if it's equal to

24:23.310 --> 24:24.510
the last name

24:28.090 --> 24:29.500
then we found it.

24:29.770 --> 24:32.340
So it's true.

24:36.080 --> 24:38.570
Index found index

24:41.170 --> 24:42.910
is the current one.

24:42.960 --> 24:44.210
I one day

24:47.680 --> 24:55.180
so now that we found it we should check to see if it found it or if have all.

24:55.180 --> 24:58.690
So if we found it then how do you remove something.

24:58.690 --> 25:07.720
All we've learned so far is pop back right in our vector.

25:07.740 --> 25:08.380
OK.

25:08.660 --> 25:21.720
So how could you remove a contact at any position by only using the E by only popping the last one.

25:21.790 --> 25:24.490
So how you could do this

25:26.890 --> 25:36.220
is swapping the last one for the for the one that we found and then we'll swap it we'll swap the last

25:36.220 --> 25:40.420
one in the vector for that first one.

25:40.420 --> 25:47.140
So now that the the one we found is at the end and then we'll just pop that one.

25:47.530 --> 25:54.790
So in order to do this we'll need the swap function and we could again we could write it ourselves.

25:54.820 --> 26:10.390
But actually an algorithm that will need anyway it has the swap functions for a swap and sort K so what's

26:10.850 --> 26:22.210
let's use it so we'll swap the one that we found with the very last the very last one if there is any.

26:22.520 --> 26:33.270
So I'll say swap and say contacts eata contacts.

26:34.800 --> 26:37.850
Or of the found index right.

26:38.410 --> 26:41.090
Swap this one with the last one

26:44.640 --> 26:46.300
how to get the last one.

26:46.300 --> 26:49.340
Well it's fairly simple.

26:49.550 --> 26:55.360
Contacts the contacts got size right.

26:55.430 --> 26:57.880
Minus one right.

26:57.980 --> 27:05.390
So remember that vectors are effectively just an array and always to get the very last element in an

27:05.390 --> 27:06.290
array.

27:06.320 --> 27:10.830
It's always the length of the reais minus one for that index.

27:10.840 --> 27:11.540
OK.

27:11.840 --> 27:25.480
So this will put the found index at the end and and then all you have to do is say contact D-B dot contacts

27:27.000 --> 27:38.550
up pop back gay I'll remove it and then we'll just say well I moved out.

27:41.100 --> 27:41.790
Moved

27:46.940 --> 27:47.980
first.

27:48.150 --> 27:49.010
I mean

27:52.090 --> 27:52.740
last night

27:57.960 --> 27:59.760
from contex

28:04.630 --> 28:05.630
like that.

28:05.860 --> 28:09.860
And if we didn't find it we're just output to the user that we didn't find it.

28:10.020 --> 28:11.350
Yeah.

28:12.430 --> 28:14.700
Could not find

28:18.100 --> 28:19.750
his name.

28:23.380 --> 28:24.250
Last name

28:27.350 --> 28:29.410
in.

28:33.870 --> 28:36.560
Resemble.

28:36.640 --> 28:44.560
And so it's kind of go over this one more time so we have no we have no contacts don't do this option.

28:44.560 --> 28:47.770
All right and we use this return with nothing.

28:47.770 --> 28:52.580
I think that's the first time we've ever seen this use use this way.

28:52.780 --> 28:59.920
So if it's a void function and you return nothing they will just exit the function and just exit.

29:00.010 --> 29:09.430
It's a function that day and we'll get the first name the last name and we'll search obviously search

29:09.430 --> 29:16.320
the contacts D-B see if we can find someone with that first name and that last name.

29:16.540 --> 29:25.150
And if we do we'll effectively store that index and say that we found it right in now we'll actually

29:25.150 --> 29:28.220
break out of the loop on the next iteration.

29:28.230 --> 29:29.000
Okay.

29:29.710 --> 29:39.670
And then if we found it we'll swap that index the found index with the very last very last

29:42.210 --> 29:43.020
index.

29:43.120 --> 29:50.820
OK the last element of the vector and then pop the last element and then say it.

29:51.070 --> 29:51.860
OK.

29:52.270 --> 29:55.800
So let's think we've set this all up.

29:55.810 --> 29:59.660
So let's run this and see what happens.

30:04.520 --> 30:06.290
So it's display.

30:06.290 --> 30:10.150
So we have Fred and Barney.

30:10.420 --> 30:12.210
So let's remove.

30:12.640 --> 30:20.150
So enter the first name let's remove Fred.

30:20.380 --> 30:24.640
So he's been removed from contacts and let's see if that's actually true.

30:25.050 --> 30:26.660
And all we have is Barnie.

30:26.940 --> 30:28.390
OK.

30:28.620 --> 30:29.770
It's quiet.

30:30.230 --> 30:34.160
And that's actually check to see

30:36.430 --> 30:37.330
if

30:43.070 --> 30:48.600
it's checked to see if we don't have fretted more.

30:48.970 --> 30:52.700
And if you look at the contacts we don't have right.

30:52.820 --> 30:53.320
OK.

30:55.950 --> 31:03.720
Now the last thing we need to do is say change the display option to have the user choose the order

31:03.720 --> 31:05.380
in which to display.

31:05.460 --> 31:16.290
So we can either sort it by first name or sort of a last name so let's implement that display function

31:16.670 --> 31:18.910
and play option.

31:19.580 --> 31:22.580
So here we will

31:25.130 --> 31:29.500
we should again check to see if we have anything in the first place.

31:30.070 --> 31:31.440
Let's do that.

31:31.700 --> 31:33.560
Read up on daks

31:36.760 --> 31:38.950
size.

31:39.040 --> 31:43.330
If you're less than or equal to zero then just return right.

31:48.340 --> 31:50.410
Turn immediately say

31:53.710 --> 31:57.060
you got it.

31:57.160 --> 32:01.310
It's that way.

32:03.140 --> 32:12.030
But if we do have contacts we shifted out to the user whether or how you want to sort it.

32:12.330 --> 32:13.200
So

32:25.440 --> 32:32.700
but if we do have contacts we shared with the user how they want to sort it.

32:32.720 --> 32:34.830
So let's give them two options.

32:34.880 --> 32:44.840
Current star search options and options will be by first name.

32:44.940 --> 32:47.180
After this one and all for this one

32:49.950 --> 32:54.600
last name in the for option

32:59.280 --> 33:04.880
in we'll say option to get character

33:07.790 --> 33:11.010
these shoes.

33:11.290 --> 33:14.020
Or at option

33:16.570 --> 33:20.570
two new lines for first name

33:24.620 --> 33:33.750
or 0 for last.

33:34.120 --> 33:35.910
It's her choice

33:40.900 --> 33:42.520
put error string

33:45.310 --> 33:48.940
and sort options options

33:51.490 --> 33:55.270
and two and we'll say it's

34:03.430 --> 34:06.520
an check to see what option we got.

34:06.700 --> 34:13.530
The option is it's a search or this should be sort of option.

34:13.530 --> 34:13.850
Sorry

34:19.610 --> 34:28.060
if the option you got is the first one that's first name since its first name.

34:30.830 --> 34:33.820
And we'll sort it by the first

34:37.210 --> 34:43.470
so contacts the bead contacts again.

34:47.230 --> 34:52.810
Contacts Heebee dot contacts dot and.

34:53.680 --> 35:04.730
But we need a we need an actual function that wants to do the comparison and we don't have that yet.

35:04.870 --> 35:11.210
So let's just write the two cases first.

35:11.390 --> 35:12.330
Copy this

35:19.580 --> 35:23.650
in lets just right now kind of.

35:23.650 --> 35:24.570
We don't have it yet.

35:24.740 --> 35:29.840
We'll here will say compare first name

35:32.750 --> 35:53.730
and here you will say hair lasting OK and let's define these functions here let's declare them at least.

35:53.970 --> 35:59.590
Compare first name and it always returns a boolean.

35:59.610 --> 36:09.180
It always takes in the actual type that the vector holds.

36:09.180 --> 36:14.370
So in this case though it will be a contes RAF contact

36:17.630 --> 36:21.500
which is called C one and constant contact

36:24.380 --> 36:29.510
is to notice that these are passed by that Vout.

36:45.890 --> 36:51.370
So identical and actually implement them down here

36:54.920 --> 37:04.840
and actually implement them kind of below or display functions so close together.

37:05.150 --> 37:13.830
So strings actually are able to be compared with the greater than or less than sine.

37:13.850 --> 37:17.860
So that's kind of one nice thing.

37:18.170 --> 37:30.240
Well it doesn't really say which order to sort them so we'll just say see one dot first name.

37:30.320 --> 37:34.810
It's less than c to dot first.

37:36.050 --> 37:40.070
OK so you can actually compare them and it'll actually do what you think it should.

37:40.070 --> 37:45.710
So in this case we're sorting them in ascending order.

37:45.710 --> 37:47.390
And what does that mean for strings.

37:47.390 --> 37:52.130
Well a will be first then be its center.

37:52.190 --> 37:53.160
OK.

37:53.270 --> 37:57.070
And will do the exact same thing for last

38:07.790 --> 38:21.300
like so there is one less thing we have to do and that is to change the display option to pass the context

38:21.300 --> 38:25.620
D-B not by Konst reference but just by reference.

38:25.920 --> 38:32.480
And that is because we're changing the contact's order right.

38:32.610 --> 38:36.920
So if we change it then we can't pass it by conc reference.

38:37.100 --> 38:39.420
Change that.

38:39.600 --> 38:43.550
So leave it in this one right here.

38:45.480 --> 38:48.590
So and now if you run it

38:52.170 --> 38:57.870
in which display first name the only one so far.

38:57.870 --> 38:59.650
So let's add back in Fred

39:02.520 --> 39:18.290
Stone and one of splay last name we should see read the first and Barni the second read first or second.

39:19.110 --> 39:22.800
And -- niblets add some more

39:25.360 --> 39:40.640
stone shows the same number as Fred and let's add Beddie double She is the same as party.

39:40.640 --> 39:49.980
So we just again in stoupe my last name.

39:50.040 --> 39:56.170
Was by first name and we will see Barney Betty Fred.

39:56.320 --> 39:56.720
All right.

39:56.770 --> 40:00.570
So it's in the proper order.

40:00.660 --> 40:04.890
So that's it for this project.

40:05.790 --> 40:16.950
In the next section we'll be dealing with a new library so that it can so that we can draw our output

40:17.160 --> 40:20.490
in a different way than what we've been using.

40:20.730 --> 40:23.910
So far so far we've only ever really used

40:26.500 --> 40:29.440
see out for output.

40:29.760 --> 40:38.860
But in our game in the next year in the last section we'll be using a different way to output to the

40:38.860 --> 40:44.660
console that will be much better suited for games in general.

40:44.950 --> 40:47.270
So I will see you in the next section.
