Neue Struktur + PasswortCecker

main
Leon Schwenke 2026-03-26 21:26:19 +01:00
parent 88284631c7
commit e33044b8af
3 changed files with 65 additions and 23 deletions

View File

@ -0,0 +1,65 @@
package pr2.junit;
import java.util.Scanner;
public class PasswortChecker {
Scanner sc = new Scanner(System.in);
public static int checkPassword(String password) {
int points = 0;
boolean checkNum = false;
boolean checkSo = false;
boolean checkBig = false;
boolean checkLen = false;
//länge >8 +1 // länge -8 -1
if (checkLen == false && password.length() > 7) {
points++;
}
/* else {
points--;
}*/
for (int i = 0; i < password.length(); i ++) {
//Großbuchstaben enhalten +1 /nicht -1
if (checkBig == false && password.charAt(i) > 64 && password.charAt(i) < 90) {
points ++;
checkBig = true;
}
//Sonderzeichen enhalten +1 nicht -1
if (checkSo == false && (password.charAt(i) > 32 && password.charAt(i) < 47 ||
password.charAt(i) > 57 && password.charAt(i) < 65 ||
password.charAt(i) > 90 && password.charAt(i) < 97 ||
password.charAt(i) > 122 && password.charAt(i) < 126 )) {
points ++;
checkSo = true;
}
//Zahl enhalten +1 / nicht -1
if (checkNum == false && password.charAt(i) > 47 && password.charAt(i) < 60) {
points ++;
checkNum = true;
}
}
return points;
}
public static void main(String[] args) {
System.out.println(checkPassword("mutti"));
System.out.println(checkPassword("Mutti"));
System.out.println(checkPassword("mutti123"));
System.out.println(checkPassword("Mutti123"));
System.out.println(checkPassword("Mutti123!%"));
System.out.println(checkPassword("1234"));
}
}

View File

@ -1,23 +0,0 @@
public class Zeichenketten{
public static void main (String[] args){
char [] a = new char [4] {'J','a','v','a'};
char [] b = new char [] {'S','u','n',' ', 'M', 'i','c','r','o','s','y','s','t','e','m','s',',',' ','I','n','c','.'};
for (int i = 0; i < a.length; i++){
System.out.print(a[i]);
}
for (int i = 0; i < b.length; i++){
System.out.print(b[i]);
}
}
}

View File