1 00:00:00,440 --> 00:00:01,660 Welcome back. 2 00:00:01,660 --> 00:00:02,920 How did you do? 3 00:00:02,920 --> 00:00:06,510 Don't worry if you weren't able to complete every part of the challenge, 4 00:00:06,510 --> 00:00:09,800 it's normal to struggle when you're learning something new. 5 00:00:09,800 --> 00:00:10,998 Let's walk through my solution. 6 00:00:10,998 --> 00:00:16,420 In the Album.cs file, I added a method to the Album class. 7 00:00:16,420 --> 00:00:20,235 Remember that a methods return type is the data type of the value that will be 8 00:00:20,235 --> 00:00:21,641 returned from the method. 9 00:00:21,641 --> 00:00:26,092 So I use string for the method's return type, 10 00:00:26,092 --> 00:00:29,868 then I name my method GetDisplayText. 11 00:00:29,868 --> 00:00:33,380 After the method name, I added a pair of parentheses. 12 00:00:33,380 --> 00:00:37,820 If this method needed parameters I'd define them here between the parentheses. 13 00:00:37,820 --> 00:00:40,850 But this method won't define any parameters. 14 00:00:40,850 --> 00:00:43,440 So I'll leave this part as it is. 15 00:00:43,440 --> 00:00:48,210 Then I added a set of curly braces to define the code block for my method body. 16 00:00:48,210 --> 00:00:53,208 In order for the method to be accessible from the program.cs file main method, 17 00:00:53,208 --> 00:00:57,993 we need to include the public access modifier right before the return type. 18 00:01:00,488 --> 00:01:02,773 To return a string value from our method, 19 00:01:02,773 --> 00:01:05,720 we use the return keyword followed by a string value. 20 00:01:08,300 --> 00:01:09,540 For my string value, 21 00:01:09,540 --> 00:01:14,730 I'll use string concatenation to combine string literals and field values. 22 00:01:14,730 --> 00:01:18,398 I'll do the same thing that I was doing in the program.cs main method. 23 00:01:18,398 --> 00:01:23,360 So Album: " + Title. 24 00:01:25,782 --> 00:01:32,376 Then another string literal contain the word by, then the artist field value. 25 00:01:32,376 --> 00:01:37,150 Cmd+S or Ctrl+S to save the file and open program.cs. 26 00:01:39,060 --> 00:01:41,140 Here, I did a little bit of clean up and 27 00:01:41,140 --> 00:01:44,850 removed all of the code that didn't pertain to the album media type 28 00:01:44,850 --> 00:01:48,410 since that's the one media type that we're working with in this practice session. 29 00:01:53,540 --> 00:01:56,256 I also renamed the album variable to album 1. 30 00:01:59,335 --> 00:02:03,240 And added two more album class instances. 31 00:02:03,240 --> 00:02:07,350 var album2 = new Album. 32 00:02:07,350 --> 00:02:10,450 And for the title, how about The Wall? 33 00:02:10,450 --> 00:02:12,260 And for the artist, Pink Floyd? 34 00:02:15,298 --> 00:02:16,690 Then var album3. 35 00:02:18,050 --> 00:02:19,320 New album. 36 00:02:21,600 --> 00:02:26,644 How about Pet Sounds by The Beach Boys. 37 00:02:29,671 --> 00:02:33,400 And to write each album's media type information to the console, 38 00:02:33,400 --> 00:02:35,463 I passed a call to the album classes, 39 00:02:35,463 --> 00:02:39,139 get display text method into the console right line method call. 40 00:02:43,735 --> 00:02:45,138 First, album1. 41 00:02:45,138 --> 00:02:50,025 So, album1.GetDisplayText then 42 00:02:50,025 --> 00:02:55,075 repeat that for album2 and album3. 43 00:02:58,132 --> 00:03:00,890 And finally, I compiled and ran the program. 44 00:03:04,534 --> 00:03:09,509 Ncs star.cs, in order to include all the cs files 45 00:03:09,509 --> 00:03:14,485 in our project, then -out colon Program.exe, 46 00:03:14,485 --> 00:03:20,660 in order to name the exe file then let's also run the program. 47 00:03:20,660 --> 00:03:24,750 && space mono program.exe. 48 00:03:27,010 --> 00:03:31,170 And here is the output for all three of my album media types. 49 00:03:31,170 --> 00:03:33,180 Are you ready for the second challenge? 50 00:03:33,180 --> 00:03:37,140 When thinking about the behaviors that I wanted my media types to support, 51 00:03:37,140 --> 00:03:39,680 I remembered that sometimes I let family members and 52 00:03:39,680 --> 00:03:42,700 friends borrow items from my media library. 53 00:03:42,700 --> 00:03:48,420 So I thought it'd be helpful to add two methods, loan and return, that can 54 00:03:48,420 --> 00:03:53,020 be used to track when an item is loaned out to someone and when it's returned. 55 00:03:54,110 --> 00:03:58,250 The loan method should accept a string of the name of the person who is borrowing 56 00:03:58,250 --> 00:04:03,430 the item and store the person's name in a new field named, Loanee. 57 00:04:03,430 --> 00:04:06,690 Use a boolean field, OnLoan, to indicate whether or 58 00:04:06,690 --> 00:04:09,340 not an item has been loaned out. 59 00:04:09,340 --> 00:04:12,140 The return method should reset the loan-related 60 00:04:12,140 --> 00:04:14,460 fields to their default values. 61 00:04:14,460 --> 00:04:18,850 Null for the Loanee field and False for the OnLoan field. 62 00:04:18,850 --> 00:04:22,990 Unlike the getDisplayText method, neither of these methods, loan or 63 00:04:22,990 --> 00:04:25,670 return, will return a value. 64 00:04:25,670 --> 00:04:28,060 Speaking of the getDisplayText method, 65 00:04:28,060 --> 00:04:33,660 update it to include the loan related field items if the item is out on loan. 66 00:04:33,660 --> 00:04:37,875 For example, if an album is currently on loan, it should display the text 67 00:04:37,875 --> 00:04:42,670 Album:Yellow Submarine by the Beatles, and then in parentheses, 68 00:04:42,670 --> 00:04:47,370 Currently on loan to Joe Smith, the name of the person who borrowed it. 69 00:04:47,370 --> 00:04:52,532 And lastly, to test your changes, update the program.cs file to call the loan and 70 00:04:52,532 --> 00:04:54,270 return methods. 71 00:04:54,270 --> 00:04:58,420 Be sure to use the get display text method to write the media type information to 72 00:04:58,420 --> 00:05:02,060 the console after calling the loan and return methods. 73 00:05:02,060 --> 00:05:05,830 They'll help you to determine if the new methods are working properly. 74 00:05:05,830 --> 00:05:08,230 And that's the second challenge. 75 00:05:08,230 --> 00:05:10,170 After the break, I'll show you my solution.