Пример #1
0
        public static void AddNewVehicle(string i_LicenseNumberForNewVehicle, string i_OwnerName, string i_OwnerPhoneNumber, Vehicle i_VehicleToReadyToInsert)
        {
            VehicleInTheGarage createdVehicle;

            createdVehicle = new VehicleInTheGarage(i_OwnerName, i_OwnerPhoneNumber, i_VehicleToReadyToInsert);
            m_MyGarage.Add(i_LicenseNumberForNewVehicle, createdVehicle);
        }
Пример #2
0
            public bool ChargeOrFuelVehicle(float i_AmountToAdd, string i_LicenseID, int i_GasType)
            {
                bool isCarCharged = false;
                VehicleInTheGarage vehicleToFill = null;

                isCarCharged = IsTheVehiclesExsitsInTheGarage(i_LicenseID, ref vehicleToFill);
                if (isCarCharged)
                {
                    if ((!(vehicleToFill.Vehicle.EngineType is ElectricEngine) && i_GasType == 0) || (!(vehicleToFill.Vehicle.EngineType is GasEngine) && i_GasType != 0))
                    {
                        throw new ArgumentException();
                    }
                    else if (vehicleToFill.Vehicle.EngineType is ElectricEngine)
                    {
                        vehicleToFill.Vehicle.EngineType.ChargeOrFuelEngine(i_AmountToAdd);
                    }
                    else
                    {
                        eGasType gasTypeToFill = (eGasType)i_GasType;
                        if (!(gasTypeToFill == ((GasEngine)vehicleToFill.Vehicle.EngineType).GasType))
                        {
                            throw new ArgumentException();
                        }

                        vehicleToFill.Vehicle.EngineType.ChargeOrFuelEngine(i_AmountToAdd);
                    }
                }

                return(isCarCharged);
            }
Пример #3
0
            public bool LogicChangeVehicleStatus(string i_LicenseID, int i_NewModeForChange)
            {
                VehicleInTheGarage vehicleForChangeStatus = null;
                bool isExsitstVehicle = IsTheVehiclesExsitsInTheGarage(i_LicenseID, ref vehicleForChangeStatus);

                if (isExsitstVehicle)
                {
                    vehicleForChangeStatus.StatusOfVehicle = (eStatusVehicle)i_NewModeForChange;
                }

                return(isExsitstVehicle);
            }
Пример #4
0
            public bool BlowVehicleAirPressurePerLicenseID(string i_LicenseID)
            {
                bool vehicleFound = false;
                VehicleInTheGarage vehicleToBlowWheels = null;

                vehicleFound = IsTheVehiclesExsitsInTheGarage(i_LicenseID, ref vehicleToBlowWheels);
                if (vehicleFound)
                {
                    vehicleToBlowWheels.Vehicle.BlowAirToMax();
                }

                return(vehicleFound);
            }
Пример #5
0
            public bool IsTheVehiclesExsitsInTheGarage(string i_LicenseID, ref VehicleInTheGarage o_VehicleForLook)
            {
                bool isFoundVehicle = false;

                foreach (VehicleInTheGarage vehicle in m_Vehicles)
                {
                    if (vehicle.Vehicle.LicenseID == i_LicenseID)
                    {
                        o_VehicleForLook = vehicle;
                        isFoundVehicle   = true;
                        break;
                    }
                }

                return(isFoundVehicle);
            }
Пример #6
0
            public bool LogicDisplayVehicleDetailsPerLicenseID(string i_LicenseID, ref StringBuilder o_VehicleDeatails)
            {
                VehicleInTheGarage vehicleLookFor = null;
                bool   isFoundVehicle             = IsTheVehiclesExsitsInTheGarage(i_LicenseID, ref vehicleLookFor);
                string printLine;

                foreach (VehicleInTheGarage vehicle in m_Vehicles)
                {
                    if (vehicle.Vehicle.LicenseID == i_LicenseID)
                    {
                        vehicleLookFor = vehicle;
                        isFoundVehicle = true;
                        break;
                    }
                }

                if (isFoundVehicle)
                {
                    printLine = string.Format("The details of vehicle Liecense {0}:", vehicleLookFor.Vehicle.LicenseID);
                    o_VehicleDeatails.AppendLine(printLine);
                    printLine = string.Format("Owner's name: {0}", vehicleLookFor.NameOfOwner);
                    o_VehicleDeatails.AppendLine(printLine);
                    printLine = string.Format("Owner's phone: {0}", vehicleLookFor.PhoneOfOwner);
                    o_VehicleDeatails.AppendLine(printLine);
                    printLine = string.Format("Status of vehicle: {0}", vehicleLookFor.StatusOfVehicle);
                    o_VehicleDeatails.AppendLine(printLine);
                    printLine = string.Format("Model name: {0}", vehicleLookFor.Vehicle.ModelName);
                    o_VehicleDeatails.AppendLine(printLine);
                    Type typeOfEngine = vehicleLookFor.Vehicle.EngineType.GetType();
                    if (typeOfEngine.Equals(typeof(GasEngine)))
                    {
                        printLine = string.Format("Engine type: gas");
                    }
                    else
                    {
                        printLine = string.Format("Engine type: electric");
                    }

                    o_VehicleDeatails.AppendLine(printLine);
                    vehicleLookFor.Vehicle.m_EngineType.GetEngineDetails(ref o_VehicleDeatails);
                    printLine = string.Format("Percentage of energy remaining: {0}%", vehicleLookFor.Vehicle.PrecentageOfEnergyLeft);
                    o_VehicleDeatails.AppendLine(printLine);
                    vehicleLookFor.Vehicle.GetVehicleDetails(ref o_VehicleDeatails);
                }

                return(isFoundVehicle);
            }