-1
Javaコードのヘルプが必要です。何らかの理由でSystem.out.println("Username does not exist");
をスキップします。私はほぼ{}
のどこかでうんざりしていると確信しています。ヘルプをいただければ幸いです。JavaはSystem.out.println()の行をスキップします。
更新日:
import java.util.Scanner;
class Bot {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Do you want to start the bot?");
String startup = input.next();
if (startup.equalsIgnoreCase("yes") || startup.equalsIgnoreCase("y")) {
System.out.println("Okay, starting...");
System.out.println("Please type your username");
String user = input.next();
if (user.equalsIgnoreCase("admin")) {
System.out.println("Valid username. Please type your password.");
String pass = input.next();
if (pass.equalsIgnoreCase("admin") || pass.equalsIgnoreCase("root")) {
System.out.println("Logging in...");
} else if (!(pass.equalsIgnoreCase("admin") || pass.equalsIgnoreCase("root"))) {
System.out.println("Wrong password.");
} else {
System.out.println("Username does not exist");
}
;
}
} else if (startup.equalsIgnoreCase("no") || startup.equalsIgnoreCase("n")) {
System.out.println("Okay, shutting down...");
} else {
System.out.println("Please answer with 'yes', 'y', 'no' or 'n', not '" + startup + "'.");
}
}
};
オリジナル:
class Bot {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Do you want to start the bot?");
String startup = input.next();
if (startup.equalsIgnoreCase("yes") || startup.equalsIgnoreCase("y")) {
System.out.println("Okay, starting...");
System.out.println("Please type your username");
String user = input.next();
if (user.equalsIgnoreCase("admin")) {
System.out.println("Valid username. Please type your password.");
String pass = input.next();
if (pass.equalsIgnoreCase("admin") || pass.equalsIgnoreCase("root")) {
System.out.println("Logging in...");
} else if (!(pass == "admin")) {
System.out.println("Wrong password.");
} else if (!(user == "admin")) {
System.out.println("Username does not exist");
}
;
}
} else if (startup.equalsIgnoreCase("no") || startup.equalsIgnoreCase("n")) {
System.out.println("Okay, shutting down...");
} else {
System.out.println("Please answer with 'yes', 'y', 'no' or 'n', not '" + startup + "'.");
}
}
};
まだ動作しません。 @Androidas – Vena