Fame Devon wrote:This was my initial objective. I've tried to improvise a bit, but the code is almost the same.
First, let me say that writing down objectives is a very good habit to get into. Keep it up.
Second: Part of the art of programming is to break up problems in to manageable chunks. Right now, your code is all in one big clump. One way to go about it would be to come up with methods for each of your major choices, eg:
Do you see how much more readable it is? And all you need to do is move all that "body" code to its own method.
You'll discover, as you get more into programming, that you want to keep your
main() methods as
small as possible.
You might also want to have a look at
Java's
switch statement, which makes this sort of "choice" logic even more readable (in my opinion), but don't worry about it too much; your if...else is also fine.
Also, I'd think about creating a
Movie class rather than just handling Strings. Right now it may only have a name, but later on you'll be able to add other pieces of info to it (eg, producer, running time) and store it to/read it from your file as well.
And then your option 2 might look like:
List<Movie> list = getMoviesFrom(movieFile);
HIH
Winston