From 1bf7290dbf99bea4a5d7a39661aa8794ae0df1e3 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 10 Nov 2020 00:03:29 +0300 Subject: [PATCH] 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 --- src/Street.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Street.java b/src/Street.java index 3cc7cd4..167e829 100644 --- a/src/Street.java +++ b/src/Street.java @@ -31,6 +31,15 @@ public class Street { 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() { return numberOfLanes; } @@ -41,7 +50,6 @@ public class Street { public double capcity() { double totalLength = length * numberOfLanes; - //TODO Ammar return (total length - (length of cars + padding)) double totalLenthofCar=0; for(int i=0;i 0) { + if(capcity() > vehicle.getVehicleSize() + 0.5) { //adds incoming vehicle in last. vehicles.add(vehicle); } - //TODO Ammar i hope that } }