From 3e1b1f162cc447f8521b72623f8bd40a17d671ee Mon Sep 17 00:00:00 2001 From: Asaad Dadoush Date: Sat, 14 Nov 2020 16:31:43 +0300 Subject: [PATCH] Add UID for Sedan / SUV / Truck --- src/SUV.java | 15 ++++++++++++++- src/Sedan.java | 20 ++++++++++++++++++-- src/Truck.java | 16 +++++++++++++--- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/SUV.java b/src/SUV.java index 2da980e..21cdc81 100644 --- a/src/SUV.java +++ b/src/SUV.java @@ -1,16 +1,29 @@ public class SUV extends CivilVehicle { - + private String UID; + private static int numeberOfSUV; private final int TIME_TO_FIX = 15; //in minutes public static final int MAX_FORWARD = 1300; public SUV(double vehicleSize){ super(vehicleSize); + generateUID(); } public int getTimeToFix(){ return TIME_TO_FIX; } + + private void generateUID() { + numeberOfSUV++; + this.UID = String.format("SUV%04d", numeberOfSUV); + + } + + public String getUID(){ + return this.UID; + } + } diff --git a/src/Sedan.java b/src/Sedan.java index 3f9de04..a9d1280 100644 --- a/src/Sedan.java +++ b/src/Sedan.java @@ -1,14 +1,30 @@ public class Sedan extends CivilVehicle { + private String UID; + private static int numeberOfSedan; private final int TIME_TO_FIX = 15; //in minutes public static final int MAX_FORWARD = 1500; // Meter/Min public Sedan(double vehicleSize){ super(vehicleSize); + generateUID(); } - - public int getTimeToFix(){ return TIME_TO_FIX; } + @Override + public int getTimeToFix(){ return TIME_TO_FIX; + + } + + private void generateUID() { + numeberOfSedan++; + this.UID = String.format("Sedan%04d", numeberOfSedan); + + } + + public String getUID(){ + return this.UID; + } + } diff --git a/src/Truck.java b/src/Truck.java index 310d81a..0ccb4d5 100644 --- a/src/Truck.java +++ b/src/Truck.java @@ -1,15 +1,25 @@ public class Truck extends CivilVehicle { - + private String UID; + private static int numeberOfTruck; private final int TIME_TO_FIX = 20; //in minutes - + // public static final int MAX_FORWARD = ????; //TODO what is the speed here ?? public Truck(double vehicleSize){ super(vehicleSize); + generateUID(); } public int getTimeToFix(){ return TIME_TO_FIX; } + private void generateUID() { + numeberOfTruck++; + this.UID = String.format("Truck%04d", numeberOfTruck); + } + + public String getUID(){ + return this.UID; + } + } -}