All language subtitles for 054 Movie Store – Part 3 (Solution)_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,240 --> 00:00:04,920 This video is going to cover the solution for part three, looking back at the requirement to be classified 2 00:00:04,920 --> 00:00:09,930 as another type of object, the store and the store is identified by the movies that it manages. 3 00:00:10,350 --> 00:00:15,090 A store also has four actions, adding movies, selling them rent and returning them. 4 00:00:16,160 --> 00:00:21,200 We'll start by adding the field, the movie's field is plural, which implies an array of movie objects, 5 00:00:21,200 --> 00:00:26,810 but once again, we need to use an array list because the number of elements can change, movies can 6 00:00:26,810 --> 00:00:28,520 be added and they can be removed. 7 00:00:29,180 --> 00:00:32,689 And always if a class has fields, you need to apply the big three steps. 8 00:00:32,689 --> 00:00:34,970 We need to add a constructor, a getter and a setter. 9 00:00:35,240 --> 00:00:40,220 The constructor is public shares the same name as the class and it receives no parameters. 10 00:00:41,750 --> 00:00:44,220 Because in the beginning, the list of movies should be empty. 11 00:00:44,750 --> 00:00:47,510 We're just going to set the field equal to a new array list. 12 00:00:49,810 --> 00:00:51,580 That can store movie objects. 13 00:00:56,010 --> 00:00:58,830 Now we want to add a getter that receives one parameter. 14 00:01:04,269 --> 00:01:09,430 The index of the movie object that they're trying to access, and this Geter is going to return a new 15 00:01:09,430 --> 00:01:09,940 copy. 16 00:01:12,650 --> 00:01:15,590 Of the movie Object at the requested index. 17 00:01:20,560 --> 00:01:23,540 Now we want at a Seder that receives two parameters. 18 00:01:29,960 --> 00:01:35,420 The index of the element you want to updates and a movie object that we're going to update the element 19 00:01:35,420 --> 00:01:39,710 with, then we're going to set the element at the requested index. 20 00:01:45,240 --> 00:01:48,240 Equal to a new copy of the movie Object being passed on. 21 00:01:51,470 --> 00:01:54,830 OK, that's all for the Big Three Steps now we're going to add actions. 22 00:01:57,090 --> 00:02:02,790 One action that the store can perform is at a movie to its collection, I'll create a void method named 23 00:02:02,790 --> 00:02:06,750 ad movie receives one parameter, a movie object. 24 00:02:09,360 --> 00:02:14,490 And inside the contacts array list, we're going to add a new copy of the movie Object Being Pastan. 25 00:02:20,100 --> 00:02:26,070 OK, the next action that it can perform is telemovie, the method is Void, called Sell Movie. 26 00:02:28,660 --> 00:02:32,230 And it receives one parameter, the name of the movie you want to sell. 27 00:02:34,300 --> 00:02:37,810 So what we'll do is credit for a loop that runs through the size of the array list. 28 00:02:40,340 --> 00:02:42,680 Remember, that array lists have a size knot length. 29 00:02:44,620 --> 00:02:48,880 And inside the fur loop, we're going to get the movie object at every index I. 30 00:02:52,760 --> 00:02:57,440 We'll get the name failed of that movie and we'll check if it equals the name of the movie, that was 31 00:02:57,440 --> 00:02:58,010 Pastan. 32 00:03:00,160 --> 00:03:01,300 And if that's the case. 33 00:03:02,850 --> 00:03:05,160 Then we're going to remove the movie from their list. 34 00:03:12,680 --> 00:03:14,390 We'll do the same thing for that movie. 35 00:03:14,420 --> 00:03:15,530 It's also void. 36 00:03:18,220 --> 00:03:21,790 And it receives one parameter, the name of the movie you want to rent. 37 00:03:28,090 --> 00:03:33,100 And once again, we'll need another for a loop that runs through the size of the array list, and then 38 00:03:33,100 --> 00:03:35,830 we need to get the movie object that every index I. 39 00:03:39,170 --> 00:03:41,090 Get the name field of that movie. 40 00:03:42,110 --> 00:03:45,320 And we'll check if it equals the name of the movie that was Pastan. 41 00:03:48,120 --> 00:03:48,930 Wait a second. 42 00:03:49,290 --> 00:03:54,210 The code that I'm writing now in this method is identical to the code that I wrote in cell movie. 43 00:03:56,750 --> 00:04:02,060 And if you think about it, even the signature is identical, they're both void and they receive the 44 00:04:02,060 --> 00:04:02,960 same parameter. 45 00:04:05,160 --> 00:04:09,060 And guess what, the code for returning a movie is also going to be identical. 46 00:04:10,340 --> 00:04:13,790 So instead of having three functions that are doing the exact same thing. 47 00:04:20,500 --> 00:04:22,780 We're going to create one function that's void. 48 00:04:24,330 --> 00:04:30,810 Named action, the first parameter is going to be name because all three methods are going to require 49 00:04:30,810 --> 00:04:36,540 a name and the second parameter is a string that represents the type of action they want to perform. 50 00:04:40,910 --> 00:04:44,810 Once again, will create a for loop that runs through the size of the array list. 51 00:04:51,550 --> 00:04:54,310 We're going to get the movie object that every index I. 52 00:04:57,600 --> 00:04:59,580 We'll get the name filled of that movie. 53 00:05:00,680 --> 00:05:03,950 And we'll check if it equals the name of the movie that was Pastan. 54 00:05:06,140 --> 00:05:11,810 And if this condition is true, what we do is going to depend on the action parameter, so here I'll 55 00:05:11,830 --> 00:05:14,930 create a switch statement that runs against a list of cases. 56 00:05:18,640 --> 00:05:19,900 If the cases sell. 57 00:05:22,170 --> 00:05:24,360 Then we're going to remove the movie from the collection. 58 00:05:32,210 --> 00:05:33,560 If the case is rent. 59 00:05:35,780 --> 00:05:39,230 Then we're going to set the availability of that movie to false. 60 00:05:50,090 --> 00:05:51,800 And if the cases return. 61 00:05:54,740 --> 00:05:57,980 Then we're going to set the availability of that movie to trip. 62 00:06:03,700 --> 00:06:06,440 Don't forget to add the keyword at the end of each case. 63 00:06:12,100 --> 00:06:17,290 Kate, now our final task before we can test our code is that a two string method that returns a nicely 64 00:06:17,290 --> 00:06:22,840 formatted string of every movie in the array list, as always, public string to string. 65 00:06:31,050 --> 00:06:33,930 I'll create a string named temp for a temporary. 66 00:06:39,950 --> 00:06:42,560 It's going to be an empty string for now, when we return, it's. 67 00:06:51,220 --> 00:06:54,340 First will create a loop that runs through the size of the array list. 68 00:07:04,540 --> 00:07:10,150 And during each run, I'm going to get the two string of the movie object at the index eye and add the 69 00:07:10,150 --> 00:07:12,610 string to the temp variable that we're returning. 70 00:07:20,270 --> 00:07:24,890 And after adding the two string of the movie, we can add two lines so that we can separate it from 71 00:07:24,890 --> 00:07:26,720 the next two string they got to Pastan. 72 00:07:30,320 --> 00:07:35,750 And that's it now we got to test our code inside main kryten object of the store class. 73 00:07:49,830 --> 00:07:54,840 And the store is going to start by adding three movies, I'm going to use the values from the article. 74 00:08:04,680 --> 00:08:06,150 Store, ad movie. 75 00:08:10,520 --> 00:08:13,130 I'll add the first one, The Shawshank Redemption. 76 00:08:31,860 --> 00:08:34,679 And I'm going to copy this format for the two other movies. 77 00:08:59,050 --> 00:09:00,520 And now we can just print the story. 78 00:09:21,270 --> 00:09:27,780 And good returns, a nicely formatted string of every movie in the movie store, so the ad action works. 79 00:09:27,810 --> 00:09:29,460 Now I'm going to test the cell action. 80 00:09:44,760 --> 00:09:46,320 I'm going to sell The Godfather. 81 00:09:59,530 --> 00:10:04,390 And Perfect's, after selling The Godfather, it gets removed from our collection. 82 00:10:07,280 --> 00:10:09,650 Now I'm going to rent out The Shawshank Redemption. 83 00:10:22,990 --> 00:10:23,890 We run the code. 84 00:10:28,620 --> 00:10:31,360 And The Shawshank Redemption is not in stock anymore. 85 00:10:31,890 --> 00:10:32,440 Beautiful. 86 00:10:32,820 --> 00:10:34,060 That is all for part three. 87 00:10:34,080 --> 00:10:35,580 I'll see you in part for. 8756

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.