Ammar: Street.addVehicle() and capacity():

This commit is contained in:
HeshamTB 2020-11-09 12:24:51 +03:00
parent 4dde706eda
commit 11252e7996
Signed by: Hesham
GPG Key ID: 74876157D199B09E

View File

@ -42,7 +42,11 @@ public class Street {
public double capcity() { public double capcity() {
double totalLength = length * numberOfLanes; double totalLength = length * numberOfLanes;
//TODO Ammar return (total length - (length of cars + padding)) //TODO Ammar return (total length - (length of cars + padding))
return 0; double totalLenthofCar=0;
for(int i=0;i<vehicles.size();i++) {
totalLenthofCar+=vehicles.get(i).getVehicleSize();
}
return totalLength -(totalLenthofCar + 0.5);
} }
public boolean canTakeVehicles( Vehicle vehicle ) { public boolean canTakeVehicles( Vehicle vehicle ) {
@ -53,7 +57,12 @@ public class Street {
} }
public void addVehicle( Vehicle vehicle ) { public void addVehicle( Vehicle vehicle ) {
//TODO Ammar if(capcity()>0) {
for(int i=0;i<getVehicles().size();i++) {
addVehicle.set(i, getVehicles().get(i));
}
}
//TODO Ammar i hope that
} }
} }