我试图将其带到用户按下数字的位置,然后他们输入他们想要查看的可用选项的字符串。到目前为止,一切正常,除了当用户输入字符串时,它没有给出首选输出.. *显示电子邮件而不是颜色、用户 ID 等。这是我的代码.. 再次感谢!
public static void printStuff(Record[] objects) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the number and record name you would like to see");
int x = in.nextInt();
String bean = in.next();
if (x == 1 || x == 2 || x == 3 || x == 4 || x == 5 && bean.equals("email")) {
System.out.println(objects[x].getEmail());
}
else if (x == 1 || x == 2 || x == 3 || x == 4 || x == 5 && bean.equals("name")) {
System.out.println(objects[x].getfirstName());
}
else if (x == 1 || x == 2 || x == 3 || x == 4 || x == 5 && bean.matches("last name")) {
System.out.println(objects[x].getlastName());
}
else if (x == 1 || x == 2 || x == 3 || x == 4 || x == 5 && bean.matches("balance")) {
System.out.println(objects[x].getBalance());
}
else if (x == 1 || x == 2 || x == 3 || x == 4 || x == 5 && bean.matches("color")) {
System.out.println(objects[x].getColor());
}
else if (x == 1 || x == 2 || x == 3 || x == 4 || x == 5 && bean.matches("idnumber")) {
System.out.println(objects[x].getnumID());
}
}
大话西游666
眼眸繁星
牧羊人nacy
相关分类