u17
This commit is contained in:
parent
2ae18ee6fb
commit
971a07a3af
Binary file not shown.
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue