This commit is contained in:
Luca Conte 2022-11-17 16:17:56 +01:00
parent 2ae18ee6fb
commit 971a07a3af
2 changed files with 37 additions and 0 deletions

BIN
uebungen/u17/Geheim.class Normal file

Binary file not shown.

37
uebungen/u17/Geheim.java Normal file
View File

@ -0,0 +1,37 @@
import java.util.Scanner;
/**
* Klasse zum Authentifizieren von Benutzern mittels eines Geheimwortes
*/
public class Geheim {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
/** Tabelle aller User (index 0 : Username, index 1: Passwort) */
String users[][] = {
{ "doors", "lightmyfire" },
{ "gates", "dos" },
{ "dent", "42" }
};
System.out.print("Benutzername bitte: ");
String username = console.next();
System.out.print("Geheimwort bitte: ");
String geheimwort = console.next();
for (int i = 0; i < users.length; i++) {
if (username.equals(users[i][0])) {
if (geheimwort.equals(users[i][1])) {
System.out.println("richtig");
return;
} else {
System.out.println("Benutzername richtig, Geheimwort falsch");
return;
}
}
}
System.out.println("falsch");
}
}