ternären Operator in Methode freieSitze() angewendet
This commit is contained in:
parent
ef8d621a58
commit
731818535a
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
|
@ -136,19 +136,15 @@ public class Main_v1 {
|
|||
}
|
||||
|
||||
static int freieSitze(int anzahlSitze) {
|
||||
int zaehler = 0;
|
||||
int zaehler;
|
||||
for (int i = 0; i < sitzplan.length; i++) {
|
||||
zaehler = 0;
|
||||
for (int j = 0; j < sitzplan[i].length; j++) {
|
||||
if (sitzplan[i][j].isStatus()) {
|
||||
zaehler++;
|
||||
} else {
|
||||
zaehler = 0;
|
||||
}
|
||||
zaehler = sitzplan[i][j].isStatus() ? zaehler + 1 : 0;
|
||||
if (zaehler >= anzahlSitze) {
|
||||
return sitzplan[i][j - (zaehler - 1)].getNummer();
|
||||
}
|
||||
}
|
||||
zaehler = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,11 +129,7 @@ public class Main_v2 {
|
|||
static int freieSitze(int anzahlSitze) {
|
||||
int zaehler = 0;
|
||||
for (int i = 0; i < sitzplan.size(); i++) {
|
||||
if (sitzplan.get(i).isStatus()) {
|
||||
zaehler++;
|
||||
} else {
|
||||
zaehler = 0;
|
||||
}
|
||||
zaehler = sitzplan.get(i).isStatus() ? zaehler + 1 : 0;
|
||||
if (zaehler == anzahlSitze) {
|
||||
return sitzplan.get(i - (zaehler - 1)).getNummer();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue