1 00:00:01,020 --> 00:00:03,180 To spice things up a little bit, 2 00:00:03,240 --> 00:00:07,470 I've prepared some fun examples. For each example, 3 00:00:07,470 --> 00:00:13,380 I'll read the task, and then I'll show you what the result should look like. 4 00:00:13,450 --> 00:00:20,050 Anyway, you can always find the solutions attached to this very lesson. 5 00:00:20,220 --> 00:00:22,300 Task number one. 6 00:00:22,440 --> 00:00:25,490 Whatever text we send to the Server, 7 00:00:25,650 --> 00:00:29,070 Server returns it in ALL CAPS. 8 00:00:29,340 --> 00:00:42,030 Let's see what that looks like. 9 00:00:42,060 --> 00:00:44,820 I'm going to run several clients right away, 10 00:00:47,590 --> 00:00:59,200 and I'm going to go to - for example - the second client, and I'm going to say "hi" - it returns it in upper 11 00:00:59,200 --> 00:01:06,690 case. And then I'm going to say "exit". It returns "exit" in upper case and then the socket for this client 12 00:01:06,780 --> 00:01:08,730 is closed. 13 00:01:08,730 --> 00:01:17,820 I'm going to go to the first client, and I'm going to say something else - and then I'm going to type "EXIT" 14 00:01:17,910 --> 00:01:19,250 in all caps. 15 00:01:19,410 --> 00:01:28,630 It returns the same thing, and then the socket is closed. 16 00:01:28,640 --> 00:01:32,510 That was the first one - let me close these. 17 00:01:32,510 --> 00:01:34,950 And then let's go to the second. 18 00:01:34,970 --> 00:01:45,020 Our second task is to send some text to the server, and then the server should revert that text backwards, 19 00:01:45,380 --> 00:01:48,050 and send it back to the client. 20 00:01:48,080 --> 00:01:53,190 We end the program by typing in "exit" in the client. 21 00:01:53,240 --> 00:01:59,290 Let's see what that looks like. 22 00:01:59,530 --> 00:02:06,490 Again, I'm going to run ServerMain first, and then one client is enough. 23 00:02:06,660 --> 00:02:09,090 Let's go to clients console. 24 00:02:09,420 --> 00:02:17,970 I'm going to type in "hi", and then "blah blah" and then I'm gonna type in "exit". 25 00:02:18,080 --> 00:02:22,460 So this is what our program for the second task should look like. 26 00:02:22,460 --> 00:02:28,730 I'm going to close the client, terminate the server, and then close the server too. 27 00:02:28,880 --> 00:02:34,830 And I'm also going to close these classes. 28 00:02:34,940 --> 00:02:38,950 Let's look at our third task. 29 00:02:38,980 --> 00:02:47,890 It says that we need a client to connect to the server and then ask the client to guess a number from 30 00:02:47,890 --> 00:02:53,030 1 to 20 - each client gets their own secret 31 00:02:53,040 --> 00:02:55,070 number to guess. 32 00:02:55,120 --> 00:02:56,260 All right. 33 00:02:56,260 --> 00:03:00,560 Let's see what the solution looks like. 34 00:03:00,620 --> 00:03:05,660 I'm going to run ServerMain and then a client. 35 00:03:06,270 --> 00:03:14,760 And then another client. OK I guess this is my second client. 36 00:03:14,770 --> 00:03:16,720 Let's start with guessing. 37 00:03:22,740 --> 00:03:25,380 As soon as I guessed the number I got 38 00:03:25,410 --> 00:03:26,550 "You got it!!!" 39 00:03:26,550 --> 00:03:35,760 message from the server, and then the socket closed. So I can close this client, but I'm left with my first 40 00:03:35,760 --> 00:03:39,570 client so I'm going to try to guess the number here too. 41 00:03:43,720 --> 00:03:44,170 OK. 42 00:03:44,170 --> 00:03:46,650 This time it was eight. 43 00:03:46,690 --> 00:03:51,730 I'm going to close this client too, and terminate the server. 44 00:03:51,820 --> 00:04:02,090 So this is what bonus example 2a should look like. 45 00:04:02,110 --> 00:04:12,360 Let's go to our fourth example, or 2b. This time all of the clients are going after the same number. 46 00:04:12,400 --> 00:04:20,230 So we need to generate one secret number, and you probably can guess it already - 47 00:04:20,260 --> 00:04:26,170 this time we're going to have to generate that number in the ServerMain class. 48 00:04:26,170 --> 00:04:35,620 And then when we run clients - each of the clients is going to be chasing the same number. As soon as one 49 00:04:35,620 --> 00:04:37,900 of the clients guesses the number, 50 00:04:37,900 --> 00:04:39,530 the game is over. 51 00:04:39,550 --> 00:04:41,870 Let's see what that will look like. 52 00:04:41,890 --> 00:04:46,620 I'm going to open my three classes. 53 00:04:46,780 --> 00:04:53,260 I'm going to run ServerMain once, and then I'm going to run two clients 54 00:04:58,370 --> 00:04:58,930 here. 55 00:04:58,940 --> 00:05:11,520 I'm going to say "Harvey" for example, and then I'm going to go to my second client and I'm going to say 56 00:05:13,030 --> 00:05:13,790 "Samantha", 57 00:05:13,820 --> 00:05:15,270 for example. 58 00:05:15,760 --> 00:05:16,260 OK. 59 00:05:16,350 --> 00:05:19,410 Let's get to the guessing part. 60 00:05:36,410 --> 00:05:37,160 OK, I was beginning to think it was going to be the very last number. 61 00:05:37,170 --> 00:05:40,680 OK, I was beginning to think it was going to be the very last number. 62 00:05:40,680 --> 00:05:41,280 OK, I was beginning to think it was going to be the very last number. 63 00:05:41,280 --> 00:05:43,470 So Samantha got the number. 64 00:05:43,470 --> 00:05:46,200 Let's see what's going on with Harvey. 65 00:05:46,200 --> 00:05:51,890 If I try and guess a number here - it's already been guessed. 66 00:05:52,020 --> 00:05:59,820 And this is the message that I get from the server - that Samantha has already guessed the number. 67 00:05:59,820 --> 00:06:02,520 That's all the explanations you'll need. 68 00:06:02,520 --> 00:06:06,410 You can find the solutions attached to this lesson, 69 00:06:06,420 --> 00:06:13,860 but if you have any additional questions, just send me a message or post your question in the Q&A section. 70 00:06:13,860 --> 00:06:14,460 but if you have any additional questions, just send me a message or post your question in the Q&A section.