Leerzeichen erlauben
This commit is contained in:
parent
77f4a7ba2b
commit
8bae4ff05a
|
|
@ -15,12 +15,12 @@ public class Lottozahlen {
|
|||
System.out.println("Bitte geben Sie sechs, mit Kommata getrennte, Lottozahlen (1 - 49) ein. " +
|
||||
"(Beispiel: \"6,12,29,34,40,46\")");
|
||||
String eingabe = scanner.next();
|
||||
if (eingabe.matches("([1-4][0-9][,]|[0-9][,]){5}[1-4][0-9]|[0-9]")) {
|
||||
if (eingabe.matches("([\\s]*[1-4][0-9][\\s]*[,][\\s]*|[\\s]*[0-9][\\s]*[,][\\s]*){5}[1-4][0-9][\\s]*|[0-9][\\s]*")) {
|
||||
|
||||
String[] zahlen = eingabe.split("[,]");
|
||||
|
||||
for (String zahl : zahlen) {
|
||||
lottoschein.add(Integer.parseInt(zahl));
|
||||
lottoschein.add(Integer.parseInt(zahl.trim()));
|
||||
}
|
||||
|
||||
// Prüfung: Doppelte Zahlen?
|
||||
|
|
|
|||
Loading…
Reference in New Issue