-2
質問と同じです。私が問題を抱えている領域は、if/elseプロパティです。また、APIインタフェースから配列型インタフェースに変更するにはどうしたらいいでしょうか?私の書式が悪い場合は申し訳ありません。私を修正しても構いません。パスワード認証プログラムにアカウントと出力を追加するにはどうすればよいですか?
プログラムを修正し、それが意図された方法を実行している:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Scanner; // Needed for the Scanner class
public class PasswordVerifier2 {
public static void main(String[] args) throws FileNotFoundException {
Scanner keyboard = new Scanner(System.in);
String input;
System.out.print("Please enter your password: ");
input = keyboard.nextLine();
if (authenticate1(input)) {
System.out.println("This program is working if this text is found within outputfile.txt.");
File file = new File("outputfile.txt");
FileOutputStream fos = new FileOutputStream(file);
PrintStream ps = new PrintStream(fos);
System.setOut(ps);
System.out.println("This program is working if this text is found within outputfile.txt.");
}else if (authenticate2(input)) {
System.out.println("It works.");
}else{
System.out.println("Error: Wrong password.");
}
}
private static boolean authenticate1(String password1) {
return ((password1.length() == 6)
&& (password1.matches("beep11"))
&& (password1.matches("beep11"))
&& (password1.matches("beep11")));
}
private static boolean authenticate2(String password2) {
return ((password2.length() == 6)
&& (password2.matches("beep22"))
&& (password2.matches("beep22"))
&& (password2.matches("beep22")));
}
}
認証クラスのフェッチャーでエラーが発生します。正方形1に戻ってください。認証2でまだエラーがあります。 – chaosillusion
私はコードを更新しました。今は、authentication2のパスワードがどこにあるのかという問題があります。どのように私はこの作品を作るのですか?メインストリングにはもうエラーはありません。 – chaosillusion
私は答えを更新しました。 –