while (true){
String key = reader.readLine();
Movie movie = MovieFactory.getMovie(key);
if (!(key.equals("cartoon") || key.equals("thriller") || key.equals("soapOpera"))) {
reader.close();
break;
} else {
//Movie movie = MovieFactory.getMovie(key);
System.out.println(movie.getClass().getSimpleName());
}
}
In the beginning i call MovieFactory.getMovie method in the else part , it fail to pass, so i move it before if and passed.
Can anyone explain why i am wrong in the beginning? Thank you!
Finished but still left one issues
Resolved
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
KIN SOCHEAT
17 October 2019, 05:32
try
String key = null;
Solution.movie = null';
while (true){
key = reader.readLine();
movie = MovieFactory.getMovie(key);
0
Guadalupe Gagnon
16 October 2019, 13:23solution
The requirements specifically say:
"For each string entered (including the invalid string), you must call the MovieFactory.getMovie method."
The first way you were doing it did not satisfy that requirement.
+2
Wei Cui
16 October 2019, 13:27
got it! you are life saver
+1