Film[] callFilms = new Film[100];
static int numberFilm = 0;
//Search Film Method
public static void searchFilm(Film[] callFilms){
Scanner scan = new Scanner(System.in);
int condition = JOptionPane.YES_OPTION;
boolean check = true;
do{
System.out.println();
System.out.println("Search Films");
System.out.println("============");
System.out.print("Please Key-in Item Code: ");
String code = scan.nextLine();
for(int i = 0; i < numberFilm; i++){
if(code.equals(callFilms[i].getItemCode())){
JOptionPane.showMessageDialog(null, "Item Code is Found!", "Finding Successful", JOptionPane.INFORMATION_MESSAGE);
System.out.println();
System.out.println("Searching is Complete!");
System.out.println("======================");
System.out.println("Item Code: " + callFilms[i].getItemCode());
System.out.println("Title: " + callFilms[i].getTitle());
System.out.println("Description: " + callFilms[i].getDescription());
System.out.println("Language: " + callFilms[i].getLanguage());
System.out.println("Running Time(Minutes): " + callFilms[i].getRunningTime());
System.out.println("Production Company: " + callFilms[i].getProductionCompany());
System.out.println("Status: " + callFilms[i].getStatus());
System.out.println();
check = true;
}
else{
JOptionPane.showMessageDialog(null, "Item Code is Not Found!", "Finding Failure", JOptionPane.ERROR_MESSAGE);
condition = JOptionPane.showConfirmDialog(null, "Want Re-Enter Item Code?" , "Re-Enter Item Code?", JOptionPane.YES_NO_OPTION);
check = false;
}
}
}while(check == false && condition == JOptionPane.YES_OPTION);
}
just assume that callFilm.getItemCode() is nothing when i = 0;
it should be can display the "Finding Failure" JOptionPane, if i put else statement there, but it don't have display.. why?