Move counting methods to street

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2020-11-17 20:44:10 +03:00
parent b06a15e303
commit 86a4ac509a
3 changed files with 18 additions and 26 deletions

View File

@ -1,8 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" name="Hajj-simulation:jar-run">
<output-path>$PROJECT_DIR$/out/artifacts/Hajj_simulation_jar_run</output-path>
<root id="archive" name="Hajj-simulation.jar">
<element id="module-output" name="Hajj-simulation" />
</root>
</artifact>
</component>

View File

@ -335,8 +335,8 @@ public class MakkahCity {
street.getName().name(),
cap,
street.getVehicles().size(),
getNumberOfBuses(street),
getNumberOfLocalCars(street));
street.getNumberOfBuses(),
street.getNumberOfLocalCars());
}
return report;
}
@ -398,20 +398,4 @@ public class MakkahCity {
return true;
}
private static int getNumberOfBuses(Street street) {
int number = 0;
for (Vehicle vehicle : street.getVehicles()) {
if (vehicle instanceof Bus) number++;
}
return number;
}
private static int getNumberOfLocalCars(Street street) {
int number = 0;
for (Vehicle vehicle : street.getVehicles()) {
if (vehicle instanceof CivilVehicle && !(vehicle instanceof Bus)) number++;
}
return number;
}
}

View File

@ -139,4 +139,20 @@ public class Street {
}
public int getNumberOfBuses() {
int number = 0;
for (Vehicle vehicle : this.getVehicles()) {
if (vehicle instanceof Bus) number++;
}
return number;
}
public int getNumberOfLocalCars() {
int number = 0;
for (Vehicle vehicle : this.getVehicles()) {
if (vehicle instanceof CivilVehicle && !(vehicle instanceof Bus)) number++;
}
return number;
}
}