Exemple #1
0
        private static void getElectricInformation(GarageVehicle i_VehicleInGarageToWorkOn, StringBuilder i_EnergyInformation)
        {
            Electric energyType = (Electric)i_VehicleInGarageToWorkOn.OwnerVehicle.EnergyType;
            float    amountOfEnergyLeftInBatteryInHours = energyType.CurrentAmountOfEnergy;

            i_EnergyInformation.AppendLine(string.Format("It uses an electric battery and has {0} hours left in it", amountOfEnergyLeftInBatteryInHours));
        }
Exemple #2
0
        public void AddWheelDetails(string i_ManufactureName, float i_LeftedAirPressure, string i_LicenseNumber)
        {
            GarageVehicle garageVehicle = VehiclesInGarage[i_LicenseNumber];

            checkIfValiLeftedAirPressureParams(i_LeftedAirPressure, garageVehicle);
            garageVehicle.Vehicle.InitWheels(i_ManufactureName, i_LeftedAirPressure);
        }
Exemple #3
0
        private static void getFuelInformation(GarageVehicle i_VehicleInGarageToWorkOn, StringBuilder i_EnergyInformation)
        {
            Fuel   energyType = (Fuel)i_VehicleInGarageToWorkOn.OwnerVehicle.EnergyType;
            string fuelType   = Enum.GetName(typeof(Fuel.eFuelType), energyType.FuelType);
            float  amountLeftInTankInLiters = energyType.CurrentAmountOfEnergy;

            i_EnergyInformation.AppendLine(string.Format("It uses Fuel type {0} and has {1} liters left in the tank", fuelType, amountLeftInTankInLiters));
        }
Exemple #4
0
        private static void getCarInformation(GarageVehicle i_VehicleInGarageToWorkOn, StringBuilder i_VehicleSpecificInformation)
        {
            Car    ownerCar           = (Car)i_VehicleInGarageToWorkOn.OwnerVehicle;
            string numberOfDoorsInCar = Enum.GetName(typeof(Car.eNumberOfDoors), ownerCar.NumberOfDoorsInCar);
            string carColor           = Enum.GetName(typeof(Car.ePossibleCarColors), ownerCar.CarColor);

            i_VehicleSpecificInformation.AppendLine(string.Format("This car has {0} doors and is {1}.", numberOfDoorsInCar, carColor));
        }
Exemple #5
0
        public void AddModelAndLeftedEnergyPrecent(string i_VehicleModel, float i_LeftedEnergyPrecent, string i_LicenseNumber)
        {
            GarageVehicle garageVehicle = VehiclesInGarage[i_LicenseNumber];

            checkIfValidPercent(i_LeftedEnergyPrecent);
            garageVehicle.Vehicle.SetVehicleModelAndPercentage(i_LeftedEnergyPrecent, i_VehicleModel);
            garageVehicle.Vehicle.Energy.CurrentEnergy = i_LeftedEnergyPrecent / 100 * garageVehicle.Vehicle.Energy.MaxEnergy;
        }
Exemple #6
0
        private static void getBikeInformation(GarageVehicle i_VehicleInGarageToWorkOn, StringBuilder i_VehicleSpecificInformation)
        {
            Bike   ownerBike    = (Bike)i_VehicleInGarageToWorkOn.OwnerVehicle;
            string licenceType  = Enum.GetName(typeof(Bike.eTypeOfLicence), ownerBike.TypeOfLicence);
            int    engineVolume = ownerBike.EngineVolume;

            i_VehicleSpecificInformation.AppendLine(string.Format("This Bike needs a {0} type licence and its engine volume is {1}", licenceType, engineVolume));
        }
Exemple #7
0
        public string GetVehicleData(string i_RegistrationPlate)
        {
            GarageVehicle vehicleToGetData = getVehicleFromDictionary(i_RegistrationPlate);
            if (vehicleToGetData == null)
            {
                throw new ArgumentException(string.Format("Vehicle with registration plate number {0} not found ", i_RegistrationPlate));
            }

            return vehicleToGetData.ToString();
        }
Exemple #8
0
 private void checkIfValiLeftedAirPressureParams(float i_LeftedAirPressure, GarageVehicle i_GarageVehicle)
 {
     if (i_LeftedAirPressure > i_GarageVehicle.Vehicle.MaxAirPressure || i_LeftedAirPressure < 0)
     {
         throw new ValueOutOfRangeException(
                   i_GarageVehicle.Vehicle.MaxAirPressure,
                   0,
                   string.Format("Invalid Lefted Air Pressure, Value out of range - {0}.", i_LeftedAirPressure));
     }
 }
Exemple #9
0
        public void ChangeVehicleStatus(string i_PlateNumber, GarageENums.eVehicleStatus i_NewVehicleStatus)
        {
            GarageVehicle vehicleToChangeStatus = getVehicleFromDictionary(i_PlateNumber);
            if (vehicleToChangeStatus == null)
            {
                throw new ArgumentException(string.Format("Vehicle with registration plate number {0} not found ", i_PlateNumber));
            }

            vehicleToChangeStatus.VehicleStatusInGarage = i_NewVehicleStatus;
        }
Exemple #10
0
        public void InflateVehicleWheelsToMax(string i_PlateNumber)
        {
            GarageVehicle vehicleToInflateWheels = getVehicleFromDictionary(i_PlateNumber);
            if (vehicleToInflateWheels == null)
            {
                throw new ArgumentException(string.Format("Vehicle with registration plate number {0} not found ", i_PlateNumber));
            }

            foreach (Wheel wheel in vehicleToInflateWheels.Vehicle.Wheels)
            {
                wheel.InflateWheelToMax();
            }
        }
Exemple #11
0
        public string getFullVehicleDetailsByLicenseNumber(string i_VehicleLicenseNumber)
        {
            GarageVehicle vehicleInGarageToWorkOn = GetGarageVehicleByLicenseNumber(i_VehicleLicenseNumber);
            StringBuilder fullDetailsMessege      = new StringBuilder();

            fullDetailsMessege.AppendLine(string.Format("The Model name of this vehicle is: {0}", vehicleInGarageToWorkOn.OwnerVehicle.ModelName));
            fullDetailsMessege.AppendLine(string.Format("The Owner's name is: {0}", vehicleInGarageToWorkOn.OwnerName));
            fullDetailsMessege.AppendLine(string.Format("The state of the vehicle in the gargae is: {0}", Enum.GetName(typeof(GarageVehicle.eVehicleState), vehicleInGarageToWorkOn.VehicleState)));
            fullDetailsMessege.AppendLine(string.Format("The State of the Wheels is: {0}{1}", Environment.NewLine, getWheelsInformation(vehicleInGarageToWorkOn)));
            fullDetailsMessege.AppendLine(getEnergyInformation(vehicleInGarageToWorkOn));
            fullDetailsMessege.AppendLine(getVehicleSpecficInformation(vehicleInGarageToWorkOn));

            return(fullDetailsMessege.ToString());
        }
        public void AddVehicle(string i_OwnerPhone, string i_OwnerName, Vehicle i_NewVehicle)
        {
            string newVehicleLicenseNumber = i_NewVehicle.LicenseNumber;

            if (m_GarageVehicles.ContainsKey(newVehicleLicenseNumber))
            {
                m_GarageVehicles[newVehicleLicenseNumber].FixState = GarageEnums.eFixState.BeingFixed;
                throw new ArgumentException("Vehicle Already exist - Moved the vehicle to being fixed state.");
            }

            GarageVehicle newVehicle = new GarageVehicle(i_OwnerName, i_OwnerPhone, i_NewVehicle);

            m_GarageVehicles.Add(i_NewVehicle.LicenseNumber, newVehicle);
        }
Exemple #13
0
        public void ChangeInGargeStateOfVehicle(string i_VehicleLicenseNumber, string i_NewInGargeStateOfVehicle)
        {
            GarageVehicle ownerVehicle = GetGarageVehicleByLicenseNumber(i_VehicleLicenseNumber);

            try
            {
                GarageVehicle.eVehicleState newVehicleState = (GarageVehicle.eVehicleState)Enum.Parse(typeof(GarageVehicle.eVehicleState), i_NewInGargeStateOfVehicle);
                ownerVehicle.VehicleState = newVehicleState;
            }
            catch (OverflowException ex)
            {
                throw new FormatException(k_WrongVehicleStateMessege, ex.InnerException);
            }
        }
Exemple #14
0
        private static string getWheelsInformation(GarageVehicle i_VehicleInGarageToWorkOn)
        {
            StringBuilder wheelsInformation = new StringBuilder();

            for (int wheelNumber = 0; wheelNumber < i_VehicleInGarageToWorkOn.OwnerVehicle.Wheels.Count; wheelNumber++)
            {
                wheelsInformation.AppendLine(string.Format(
                                                 "Wheel Number {0} maker is: {1} and air pressure {2}.",
                                                 wheelNumber,
                                                 i_VehicleInGarageToWorkOn.OwnerVehicle.Wheels[wheelNumber].MakerName,
                                                 i_VehicleInGarageToWorkOn.OwnerVehicle.Wheels[wheelNumber].CurrentAirPressureInWheel));
            }

            return(wheelsInformation.ToString());
        }
Exemple #15
0
        private string getEnergyInformation(GarageVehicle i_VehicleInGarageToWorkOn)
        {
            StringBuilder energyInformation = new StringBuilder();

            if (i_VehicleInGarageToWorkOn.OwnerVehicle.EnergyType is Fuel)
            {
                getFuelInformation(i_VehicleInGarageToWorkOn, energyInformation);
            }
            else
            {
                getElectricInformation(i_VehicleInGarageToWorkOn, energyInformation);
            }

            return(energyInformation.ToString());
        }
Exemple #16
0
        public Garage.GarageVehicle FindCarByLicensePlate(string i_LicensePlate)
        {
            // I've added this function
            GarageVehicle vehicleThatHasThisPlate = null;

            foreach (GarageVehicle vehicle in m_Vehicles)
            {
                if (vehicle.Vehicle.LicensePlate == i_LicensePlate)
                {
                    vehicleThatHasThisPlate = vehicle;
                    break;
                }
            }

            return(vehicleThatHasThisPlate);
        }
Exemple #17
0
        public void InsertNewVehicle(Dictionary <string, string> i_NewVehicleData, string i_VehicleType)
        {
            Dictionary <string, object> parametersForFactory = new Dictionary <string, object>();

            foreach (string key in i_NewVehicleData.Keys)
            {
                validateAndInsertToParametersDict(parametersForFactory, i_NewVehicleData, key);
            }

            VeichleFactory.ePossibleVehicleTypes typeOfVehicleToCreate = (VeichleFactory.ePossibleVehicleTypes)Enum.Parse(typeof(VeichleFactory.ePossibleVehicleTypes), i_VehicleType);
            Vehicle ownerVehicle = VeichleFactory.CreateNewVeichle(typeOfVehicleToCreate, parametersForFactory);

            GarageVehicle newVehicleInGarage = new GarageVehicle(i_NewVehicleData[GarageVehicle.k_OwnerNameKey], i_NewVehicleData[GarageVehicle.k_OwnerPhoneNumberKey], ownerVehicle);

            m_VehiclesInGarage.Add(i_NewVehicleData[k_LicenceNumberKey], newVehicleInGarage);
        }
        public void FillFuelInVehicle(string i_PlateNumber, FuelTank.eFuelType i_FuelType, float i_FuelToFill)
        {
            GarageVehicle vehicleToFillFuel = getVehicleFromDictionary(i_PlateNumber);

            if (vehicleToFillFuel == null)
            {
                throw new ArgumentException(string.Format("Vehicle with plate number {0} not found ", i_PlateNumber));
            }

            if (!(vehicleToFillFuel.Vehicle.DetailsOfVehicle.energyType is FuelTank))
            {
                throw new ArgumentException("Energy type is incompatible");
            }

            (vehicleToFillFuel.Vehicle.DetailsOfVehicle.energyType as FuelTank).FillTank(i_FuelToFill, i_FuelType);
        }
        public void ChargeElectricVehicle(string i_PlateNumber, float i_ChargeAmount)
        {
            GarageVehicle vehicleToCharge = getVehicleFromDictionary(i_PlateNumber);

            if (vehicleToCharge == null)
            {
                throw new ArgumentException(string.Format("Vehicle with plate number {0} not found ", i_PlateNumber));
            }

            if (!(vehicleToCharge.Vehicle.DetailsOfVehicle.energyType is ElectricBattery))
            {
                throw new ArgumentException("Energy type is incompatible");
            }

            (vehicleToCharge.Vehicle.DetailsOfVehicle.energyType as ElectricBattery).Charge(i_ChargeAmount);
        }
Exemple #20
0
        public void EnterNewVehicle(
            string i_VehicleOwner,
            string i_VehicleOwnerPhone,
            int i_VehicleType,
            string i_LicenseNumber)
        {
            VehicleInit   vehicleInit = new VehicleInit();
            Vehicle       vehicle;
            GarageVehicle garageVehicle;
            eVehicleTypes vehicleType;

            vehicleType = checkIfValidVehicleTypeParam(i_VehicleType);
            vehicle     = vehicleInit.InitVehicle(vehicleType);
            vehicle.SetVehicleLicenseNumber(i_LicenseNumber);
            garageVehicle = new GarageVehicle(vehicle, i_VehicleOwner, i_VehicleOwnerPhone, eVehicleStatus.IN_PROGRESS);
            m_VehiclesInGarage.Add(vehicle.LicenseNumber, garageVehicle);
        }
Exemple #21
0
        // Gets a vehicle to add, if the vehicle is already in the list then print a suitable message and change the status of vehicle to “InProgress”.
        public Dictionary <string, Dictionary <Dictionary <string, string>, string[]> > AddVehicle(string i_VehicleType, string i_EngineType, string i_LicensePlate)
        {
            Dictionary <string, Dictionary <Dictionary <string, string>, string[]> > nextInformation = null;

            if (IsExists(i_LicensePlate))
            {
                ChangeStatus(i_LicensePlate, eVehicleStatus.InProgress.ToString());
            }
            else
            {
                GarageVehicle garageVehicle = new GarageVehicle(i_VehicleType, i_EngineType, i_LicensePlate);
                nextInformation = garageVehicle.PropertiesToDictionary();

                r_GarageVehicles.Add(garageVehicle);
            }

            return(nextInformation);
        }
Exemple #22
0
        private static void getTruckInformation(GarageVehicle i_VehicleInGarageToWorkOn, StringBuilder i_VehicleSpecificInformation)
        {
            Truck  ownerTruck = (Truck)i_VehicleInGarageToWorkOn.OwnerVehicle;
            string dangerousCargo;

            if (ownerTruck.HasDangerousCargo)
            {
                dangerousCargo = k_HasDangerousCargoForTruck;
            }
            else
            {
                dangerousCargo = k_DoesNotHaveDangerousCargoForTruck;
            }

            float maxCargoWeight = ownerTruck.MaxCargoWeight;

            i_VehicleSpecificInformation.AppendLine(string.Format("This truck {0} dangerous cargo, and it can carry a maximum of {1}.", dangerousCargo, maxCargoWeight));
        }
Exemple #23
0
        public void SetMotorcycleAdditionalParams(string i_LicenseNumber, int i_LicenseType, int i_EngineCapacity)
        {
            GarageVehicle garageVehicle = VehiclesInGarage[i_LicenseNumber];

            eLicenseTypes licenseType = checkIfValidLicenseTypeParam(i_LicenseType);

            if (garageVehicle.Vehicle is ElectricMotorcycle)
            {
                ElectricMotorcycle electricMotorcycle = garageVehicle.Vehicle as ElectricMotorcycle;
                electricMotorcycle.MotorcycleDetails.LicenseType    = licenseType;
                electricMotorcycle.MotorcycleDetails.EngineCapacity = i_EngineCapacity;
            }
            else if (garageVehicle.Vehicle is FuelMotorcycle)
            {
                FuelMotorcycle fuelMotorcycle = garageVehicle.Vehicle as FuelMotorcycle;
                fuelMotorcycle.MotorcycleDetails.LicenseType    = licenseType;
                fuelMotorcycle.MotorcycleDetails.EngineCapacity = i_EngineCapacity;
            }
        }
Exemple #24
0
        private string getVehicleSpecficInformation(GarageVehicle i_VehicleInGarageToWorkOn)
        {
            StringBuilder vehicleSpecificInformation = new StringBuilder();

            if (i_VehicleInGarageToWorkOn.OwnerVehicle is Car)
            {
                getCarInformation(i_VehicleInGarageToWorkOn, vehicleSpecificInformation);
            }
            else if (i_VehicleInGarageToWorkOn.OwnerVehicle is Bike)
            {
                getBikeInformation(i_VehicleInGarageToWorkOn, vehicleSpecificInformation);
            }
            else if (i_VehicleInGarageToWorkOn.OwnerVehicle is Truck)
            {
                getTruckInformation(i_VehicleInGarageToWorkOn, vehicleSpecificInformation);
            }

            return(vehicleSpecificInformation.ToString());
        }
Exemple #25
0
        public void SetCarAdditionalParams(string i_LicenseNumber, int i_VehicleColor, int i_NumOfDoors)
        {
            GarageVehicle garageVehicle = VehiclesInGarage[i_LicenseNumber];

            eColors color      = checkIfValidColorParam(i_VehicleColor);
            eDoors  numOfDoors = checkIfValidDoorsParam(i_NumOfDoors);

            if (garageVehicle.Vehicle is FuelCar)
            {
                FuelCar fuelCar = garageVehicle.Vehicle as FuelCar;
                fuelCar.CarDetails.VehicleColor = color;
                fuelCar.CarDetails.NumOfDoors   = numOfDoors;
            }
            else if (garageVehicle.Vehicle is ElectricCar)
            {
                ElectricCar electricCar = garageVehicle.Vehicle as ElectricCar;
                electricCar.CarDetails.VehicleColor = color;
                electricCar.CarDetails.NumOfDoors   = numOfDoors;
            }
        }
Exemple #26
0
        public void ChargeElectricityBasedVehicle(string i_VehicleLicenseNumber, float i_NumberOfHoursToCharge)
        {
            GarageVehicle ownerVehicle = GetGarageVehicleByLicenseNumber(i_VehicleLicenseNumber);

            Dictionary <string, object> parametersForEnergyCharging = new Dictionary <string, object>();

            parametersForEnergyCharging.Add(Energy.k_ValueType, Electric.k_EnergyType);
            parametersForEnergyCharging.Add(Energy.k_ValueToAdd, i_NumberOfHoursToCharge);
            try
            {
                Electric ownerBattery = (Electric)ownerVehicle.OwnerVehicle.EnergyType;

                ownerVehicle.OwnerVehicle.EnergyType.AddEnergy(parametersForEnergyCharging);
                ownerVehicle.OwnerVehicle.PercentOfEnergyLeft = calculateNewPrecanteOfEnergy(ownerBattery.MaxAmountOfEnergy, ownerBattery.CurrentAmountOfEnergy);
            }
            catch (InvalidCastException ex)
            {
                throw new ArgumentException("Wrong Energy Type!", ex);
            }
        }
        public bool AddVehicleToGarage(Vehicle i_Vehicle)
        {
            if (i_Vehicle == null)
            {
                throw new NullReferenceException("Vehicle undefined, null reference received");
            }

            bool          vehicleIsInGarage = m_DictOfGarageVehicles.ContainsKey(i_Vehicle.DetailsOfVehicle.plateNumber);
            GarageVehicle vehicleToAdd;

            if (vehicleIsInGarage)
            {
                ChangeVehicleStatus(i_Vehicle.DetailsOfVehicle.plateNumber, eVehicleStatusInGarage.InRepair);
            }
            else
            {
                vehicleToAdd = new GarageVehicle(i_Vehicle);
                m_DictOfGarageVehicles.Add(i_Vehicle.DetailsOfVehicle.plateNumber, vehicleToAdd);
            }

            return(vehicleIsInGarage);
        }
Exemple #28
0
        public Dictionary <string, Dictionary <Dictionary <string, string>, string[]> > GetInformation(string i_LicensePlate)
        {
            GarageVehicle garageVehicle = FindVehicle(i_LicensePlate);

            Dictionary <string, Dictionary <Dictionary <string, string>, string[]> > vehicle_information = garageVehicle.PropertiesToDictionary();

            Dictionary <string, string> vehicleType = new Dictionary <string, string>();

            vehicleType.Add("Type", $"{garageVehicle.Vehicle.Engine.EngineType} {garageVehicle.Vehicle.GetVehicleType()}");

            Dictionary <string, string> vehicleLicensePlate = new Dictionary <string, string>();

            vehicleLicensePlate.Add("License Plate", garageVehicle.Vehicle.LicensePlate);

            Dictionary <string, string> vehicleStatus = new Dictionary <string, string>();

            vehicleType.Add("Status", garageVehicle.Status.ToString());

            vehicle_information["Vehicle"].Add(vehicleType, null);
            vehicle_information["Vehicle"].Add(vehicleLicensePlate, null);
            vehicle_information["Vehicle"].Add(vehicleStatus, null);

            Dictionary <Dictionary <string, string>, string[]> properties_owner = new Dictionary <Dictionary <string, string>, string[]>();

            Dictionary <string, string> ownerName = new Dictionary <string, string>();

            ownerName.Add("Name", garageVehicle.OwnerName);

            Dictionary <string, string> ownerPhoneNumber = new Dictionary <string, string>();

            ownerPhoneNumber.Add("Phone Number", garageVehicle.OwnerPhoneNumber);

            properties_owner.Add(ownerName, Enum.GetNames(typeof(eCarColor)));
            properties_owner.Add(ownerPhoneNumber, Enum.GetNames(typeof(eCarNumOfDoors)));

            vehicle_information.Add("Owner", properties_owner);

            return(vehicle_information);
        }
Exemple #29
0
        public bool AddVehicleToGarage(Vehicle i_Vehicle)
        {
            if (i_Vehicle == null)
            {
                throw new NullReferenceException("Vehicle undefined, null reference received");
            }

            bool vehicleIsInGarage = m_DictOfGarageVehicles.ContainsKey(i_Vehicle.RegistrationPlate);
            GarageVehicle vehicleToAdd;

            if (vehicleIsInGarage)
            {
                ChangeVehicleStatus(i_Vehicle.RegistrationPlate, GarageENums.eVehicleStatus.InRepair);
            }
            else
            {
                vehicleToAdd = new GarageVehicle(i_Vehicle);
                m_DictOfGarageVehicles.Add(i_Vehicle.RegistrationPlate, vehicleToAdd);
            }

            return vehicleIsInGarage;
        }
Exemple #30
0
 private void showVehiclesAccordingToState(string i_InGargeStateOfVehicleToFilterWith, StringBuilder i_ListOfVehiclesInGarage)
 {
     try
     {
         GarageVehicle.eVehicleState filterVehicleState = (GarageVehicle.eVehicleState)Enum.Parse(typeof(GarageVehicle.eVehicleState), i_InGargeStateOfVehicleToFilterWith);
         foreach (string key in m_VehiclesInGarage.Keys)
         {
             GarageVehicle currentVehicle = m_VehiclesInGarage[key];
             if (currentVehicle.VehicleState == filterVehicleState)
             {
                 i_ListOfVehiclesInGarage.AppendLine(currentVehicle.OwnerVehicle.LicenceNumber);
             }
         }
     }
     catch (OverflowException ex)
     {
         throw new FormatException(k_WrongVehicleStateMessege, ex.InnerException);
     }
     catch (ArgumentException ex)
     {
         throw new FormatException(k_WrongVehicleStateMessege, ex.InnerException);
     }
 }