Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In this video.
We're going to cover the solution for part five.
Once again, we tie everything together by adding user interactivity.
Task one tells us to make the store object a class variable because we are going to need to access it
from more than one place inside the class.
Task two is to define a function named load movies.
It takes one parameter, the file name that we're going to load movies from and the function is going
to throw a file not found exception.
First thing we're going to do is load contacts from the file name.
We can use a file input stream.
We'll create a new object of the file input stream class and pass into it the file name that we want
to connect to.
The next thing we need to do is read the data from the movies file.
So after connecting to the file will create a new getter object.
And instead of receiving input from the system, it's going to receive input from the input stream.
And then we can use a while loop to read all the data from the file that we're scanning.
The while loop will keep running as long as the file has a next line.
So it should run ten times.
And during each run, we're going to create a new movie object.
But wait.
Each movie is separated by hyphens.
We can't use Scandal.
Next, bigger scandal.
Next picks up the next value delimited by a white space.
In this case, the delimiter is two hyphens.
So during each run, we're going to have to pick up the entire line as one string.
String line is equal to scandal.
Our next line.
Based on the delimiter, we know that each line can split into three strings.
And I told you to research how the split function can be used to split a string into multiple strings.
So I hope you came up with this.
All you got to do is say line, not split.
And we're going to split the line every time there's a pair of hyphens.
If you hover on the method, it returns an array of string values, which we're going to store in an
array called words.
This array is going to contain three elements because we know that the line was split into three words.
The first word we know is the name.
The second word is the format.
And the third is the rating.
A oh rating is a double, but it's being stored as a string.
And your task was to research how to parse a double from a string.
And I hope you found something like this.
We're going to use the wrapper class double.
To pass a double.
From the string at index to.
And splendid.
And once you're done, don't forget to close the scanner object.
And that's it for the load movies function.
We'll go back to the main method we're going to call Load Movie.
And the file we're going to be loading movies from is movies that text.
Once again we get an error because the load movies method can through a file not found exception.
This is a tactics option.
So if you want to call this method, Java is going to force you to try to run the code.
And if the code happens to fail, you need to catch the file, not a found exception.
And we'll just print the message that comes out of it.
Here.
We're going to print.
Movies loaded.
Followed by two lines.
Then we'll print the two string of the store object.
And.
Okay, I want to test everything before moving on.
We write a lot of code and went at a break point right here.
Launch the debugger.
And step into the function.
I'll step over creating the file input stream as well as the scanner object.
The wire loop runs through every line in the movie file injury each run.
We're picking up the entire line.
Then we're splitting the line around every pair of hyphens.
As a result, we get an array with three values.
Then we're using these values to create a new object and add it to the collection of movies.
And you know what?
I'll never get bored of visualizing code.
It's really cool.
Now there are a lot of movies, so I'll start the debugger here.
And that's all for tasks.
One, two and three.
In the next video over an implement task for.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.