gpt4 book ai didi

Java - While 循环后的 IF 语句不起作用

转载 作者:行者123 更新时间:2023-11-29 07:50:53 25 4
gpt4 key购买 nike

<分区>

谢谢大家,但是,新问题出现了。

即使列表和用户输入正确,它仍会打印出“找不到您的电影或/和剧院。”

我发现的有关问题的事情。当任一列表中有 1 项时(电影 0-1 项和剧院 0-1 项),它不会打印出 “找不到您的电影或/和剧院。”

但是当其中任何一项(电影 1 项目和剧院 2 或电影 2 和剧院 1)中有超过 1 项时,它将打印出 if(found == false)声明。

public void addScreening(){
System.out.println("-ADD NEW SCREENING-");
String mTitle = Helper.readString("Enter movie title > ");
String tName = Helper.readString("Enter theatre name > ");

boolean found = true;

while(found == true){
for (int i = 0; i < movies.size(); i++) {
for (int j = 0; j < theatres.size(); j++) {
if ((movies.get(i).getTitle().contains(mTitle) || mTitle.contains(movies.get(i).getTitle())) &&
(theatres.get(j).getName().contains(tName) || tName.contains(theatres.get(j).getName()))) {

int year = Helper.readInt("Enter year > ");
int month = Helper.readInt("Enter month > ");
int day = Helper.readInt("Enter day > ");
int hour = Helper.readInt("Enter hour > ");
int min = Helper.readInt("Enter min > ");

screenings.add(new MovieScreening(Helper.thisDate(year,
month, day, hour, min), movies.get(i),theatres.get(j), 0));
System.out.println("Added successfully");

}else if((!movies.get(i).getTitle().contains(mTitle) || !mTitle.contains(movies.get(i).getTitle()))
|| (!theatres.get(j).getName().contains(tName) || !tName.contains(theatres.get(j).getName()))){

found = false;

}
}

}break;
}if (found == false){
System.out.println("Your movie or/and theatre cannot be found.");
found = true;
}
}

输出

-ADD NEW SCREENING-
Enter movie title > 3
Enter theatre name > 3
Enter year > 3
Enter month > 3
Enter day > 3
Enter hour > 3
Enter min > 3
Added successfully
Your movie or/and theatre cannot be found.

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com