Street:
- Added getCombinedLength(). Returns sum of the length of each lane on street - Fixed addVehicle() condition to be relative to the provided vehicle plus padding Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
7c9fd44070
commit
1bf7290dbf
@ -31,6 +31,15 @@ public class Street {
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets total length of one lane * number of lanes
|
||||||
|
* As if it is a sigle longer lane.
|
||||||
|
* @return Total length of all lanes combined
|
||||||
|
*/
|
||||||
|
public double getCombinedLength() {
|
||||||
|
return this.length * this.numberOfLanes;
|
||||||
|
}
|
||||||
|
|
||||||
public int getNumberOfLanes() {
|
public int getNumberOfLanes() {
|
||||||
return numberOfLanes;
|
return numberOfLanes;
|
||||||
}
|
}
|
||||||
@ -41,7 +50,6 @@ 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))
|
|
||||||
double totalLenthofCar=0;
|
double totalLenthofCar=0;
|
||||||
for(int i=0;i<vehicles.size();i++) {
|
for(int i=0;i<vehicles.size();i++) {
|
||||||
totalLenthofCar+=vehicles.get(i).getVehicleSize();
|
totalLenthofCar+=vehicles.get(i).getVehicleSize();
|
||||||
@ -57,11 +65,10 @@ public class Street {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addVehicle(Vehicle vehicle) {
|
public void addVehicle(Vehicle vehicle) {
|
||||||
if(capcity() > 0) {
|
if(capcity() > vehicle.getVehicleSize() + 0.5) {
|
||||||
//adds incoming vehicle in last.
|
//adds incoming vehicle in last.
|
||||||
vehicles.add(vehicle);
|
vehicles.add(vehicle);
|
||||||
}
|
}
|
||||||
//TODO Ammar i hope that
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user