From 9826110d195ff3813c174dc57971fb8daab8ddc2 Mon Sep 17 00:00:00 2001 From: Carumar <1720808@stud.hs-mannheim.de> Date: Wed, 21 May 2025 19:31:55 +0200 Subject: [PATCH] Es geht --- Passwort_Check.java | 72 ++++++++++++++++++++++----------------------- Test.java | 5 ---- 2 files changed, 36 insertions(+), 41 deletions(-) delete mode 100644 Test.java diff --git a/Passwort_Check.java b/Passwort_Check.java index c795894..179e828 100644 --- a/Passwort_Check.java +++ b/Passwort_Check.java @@ -1,42 +1,7 @@ -package uebung4; import java.util.Scanner; + public class Passwort_Check { - public static void main(String[] args) { - String passwort = null; - String checkResultat = "Passwort ist sicher."; - boolean check = true; - Scanner in = new Scanner(System.in); - System.out.println("Geben Sie ein Passwort zur überprüfung ein:"); - - passwort = in.nextLine(); - do { - checkResultat = checkLaenge(passwort); - if (checkResultat == "Passwort ist sicher.") { - checkResultat = checkKleinBuchstaben(passwort); - } - if (checkResultat == "Passwort ist sicher.") { - checkResultat = checkGrossBuchstaben(passwort); - } - if (checkResultat == "Passwort ist sicher.") { - checkResultat = checkZiffer(passwort); - } - if (checkResultat == "Passwort ist sicher.") { - checkResultat = checkSonderZeichen(passwort); - } - if (checkResultat != "Passwort ist sicher.") { - check = false; - System.out.println(checkResultat + "\n Geben Sie ein verbessertes Passwort zur überprüfung ein:"); - passwort = in.nextLine(); - } else { - check = true; - } - } while (check == false); - System.out.println(checkResultat); - System.out.println("...und Tschüss"); - in.close(); - } - public static String checkLaenge(String passwort) { String ausgabe = "Passwort ist zu kurz"; if (passwort.length() >= 20) { @@ -74,4 +39,39 @@ public class Passwort_Check { return ausgabe; } + public static void main(String[] args) { + String passwort = null; + String checkResultat = "Passwort ist sicher."; + boolean check = true; + Scanner in = new Scanner(System.in); + System.out.println("Geben Sie ein Passwort zur überprüfung ein:"); + + passwort = in.nextLine(); + do { + checkResultat = checkLaenge(passwort); + if (checkResultat == "Passwort ist sicher.") { + checkResultat = checkKleinBuchstaben(passwort); + } + if (checkResultat == "Passwort ist sicher.") { + checkResultat = checkGrossBuchstaben(passwort); + } + if (checkResultat == "Passwort ist sicher.") { + checkResultat = checkZiffer(passwort); + } + if (checkResultat == "Passwort ist sicher.") { + checkResultat = checkSonderZeichen(passwort); + } + if (checkResultat != "Passwort ist sicher.") { + check = false; + System.out.println(checkResultat + "\n Geben Sie ein verbessertes Passwort zur überprüfung ein:"); + passwort = in.nextLine(); + } else { + check = true; + } + } while (check == false); + System.out.println(checkResultat); + System.out.println("...und Tschüss"); + in.close(); + } + } diff --git a/Test.java b/Test.java deleted file mode 100644 index 9f18380..0000000 --- a/Test.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Test { - public static void main(String[] args) { - System.out.println("Hello World"); - } -}