Hallo, das ist die Aufgabe:
For every good kata idea there seem to be quite a few bad ones!
In this kata you need to check the provided array (x) for good ideas 'good' and bad ideas 'bad'. If there are one or two good ideas, return 'Publish!', if there are more than 2 return 'I smell a series!'. If there are no good ideas, as is often the case, return 'Fail!'.
Das ist mein Code dazu:
Es funktioniert in Eclipse, aber nicht bei Codewars. Meine Vermutung ist, dass auch auf ein leeres Array überprüft wird, weshalb ich beim letzten else if noch das "...|| x.length <=0" hinzugefügt habe. Dadurch ist das Problem leider noch nicht gelöst. So sieht der Error aus:

Ich weiß jetzt wirklich nicht mehr, woran es liegen könnte. Vielleicht kann mir da jemand aushelfen.
Vielen Dank
For every good kata idea there seem to be quite a few bad ones!
In this kata you need to check the provided array (x) for good ideas 'good' and bad ideas 'bad'. If there are one or two good ideas, return 'Publish!', if there are more than 2 return 'I smell a series!'. If there are no good ideas, as is often the case, return 'Fail!'.
Das ist mein Code dazu:
Java:
String[] x = {};
int count0 = 0;
String r = "";
for(int i=0; i<x.length; i++){
if(x[i].equals("good")){
count0++;
}if(count0 <= 2 && count0 != 0) {
r = "Publish!";
}else if(count0 > 2) {
r = "I smell a series!";
}else if(count0 == 0 || x.length <= 0) {
r = "Fail!";
}
}
//System.out.println(count0);
return r;
Es funktioniert in Eclipse, aber nicht bei Codewars. Meine Vermutung ist, dass auch auf ein leeres Array überprüft wird, weshalb ich beim letzten else if noch das "...|| x.length <=0" hinzugefügt habe. Dadurch ist das Problem leider noch nicht gelöst. So sieht der Error aus:

Ich weiß jetzt wirklich nicht mehr, woran es liegen könnte. Vielleicht kann mir da jemand aushelfen.
Vielen Dank