Exemplo n.º 1
0
        internal bool ValidInputCurrentEnergyCapacity(string i_InputString, eKindsOfVehicles i_eKindOfVehicle, ref float io_CurrentEnergyCapacity, float i_MaxEnergyCapacity)
        {
            bool isValid = false;

            try
            {
                io_CurrentEnergyCapacity = float.Parse(i_InputString);
                if (io_CurrentEnergyCapacity >= 0 && io_CurrentEnergyCapacity <= i_MaxEnergyCapacity)
                {
                    isValid = true;
                }
                else
                {
                    throw new ValueOutOfRangeException(i_MaxEnergyCapacity, 0, i_InputString);
                }
            }

            catch (FormatException)
            {
                Console.WriteLine("{0} is Not an Float. Please Try Again: ", i_InputString);
            }

            catch (ValueOutOfRangeException ex)
            {
                Console.WriteLine("{0}", ex.Message);
            }

            return(isValid);
        }
Exemplo n.º 2
0
        public override eKindsOfVehicles GetKindOfVehicle()
        {
            eKindsOfVehicles KindsOfVehicles = eKindsOfVehicles.ElectronicMotorCycle;

            if (m_EnergySource is Fuel)
            {
                KindsOfVehicles = eKindsOfVehicles.MotorCycle;
            }
            return(KindsOfVehicles);
        }
Exemplo n.º 3
0
        internal bool ValidInputKindOfVehicle(string i_InputKindOfVehicle, ref eKindsOfVehicles io_KindOfVehicle)
        {
            bool isValid = false;

            try
            {
                if (i_InputKindOfVehicle == "Car" || i_InputKindOfVehicle == "1")
                {
                    io_KindOfVehicle = GarageLogic.eKindsOfVehicles.Car;
                    isValid          = true;
                }
                else if (i_InputKindOfVehicle == "Electronic Car" || i_InputKindOfVehicle == "2")
                {
                    io_KindOfVehicle = GarageLogic.eKindsOfVehicles.ElectronicCar;
                    isValid          = true;
                }
                else if (i_InputKindOfVehicle == "MotorCycle" || i_InputKindOfVehicle == "3")
                {
                    io_KindOfVehicle = GarageLogic.eKindsOfVehicles.MotorCycle;
                    isValid          = true;
                }
                else if (i_InputKindOfVehicle == "Electronic MotorCycle" || i_InputKindOfVehicle == "4")
                {
                    io_KindOfVehicle = GarageLogic.eKindsOfVehicles.ElectronicMotorCycle;
                    isValid          = true;
                }
                else if (i_InputKindOfVehicle == "Truck" || i_InputKindOfVehicle == "5")
                {
                    io_KindOfVehicle = GarageLogic.eKindsOfVehicles.Truck;
                    isValid          = true;
                }
                else
                {
                    throw new ArgumentException();
                }
            }
            catch (ArgumentException)
            {
                Console.WriteLine("{0} is Not an Options. Please Try Again: [Car(1) /Electronic Car(2) /MotorCycle(3) /Electronic MotorCycle(4) /Truck(5)]", i_InputKindOfVehicle);
            }

            return(isValid);
        }
Exemplo n.º 4
0
 public float GetMaxCapacityForVehicle(eKindsOfVehicles i_eKindOfVehicle)
 {
     if (i_eKindOfVehicle == eKindsOfVehicles.Car)
     {
         return(ConstantsEnergyMaxCapacity.FuelCar);
     }
     else if (i_eKindOfVehicle == eKindsOfVehicles.ElectronicCar)
     {
         return(ConstantsEnergyMaxCapacity.ElectronicCar);
     }
     else if (i_eKindOfVehicle == eKindsOfVehicles.MotorCycle)
     {
         return(ConstantsEnergyMaxCapacity.FuelMotorCycle);
     }
     else if (i_eKindOfVehicle == eKindsOfVehicles.ElectronicMotorCycle)
     {
         return(ConstantsEnergyMaxCapacity.ElectronicMotorCycle);
     }
     else
     {
         return(ConstantsEnergyMaxCapacity.FuelTruck);
     }
 }
Exemplo n.º 5
0
        private void PrintAllVihecleDetailsByPlateNumber()//function 7
        {
            string       plateNumber;
            List <Wheel> VehicleWheels;

            plateNumber = GetExistPlateNumber();

            System.Console.WriteLine(@"
Details For The Vehicle With the Plate Number {0}

Owner's Name:.................{1}
Owner's Phone Number:.........{2}
Vehicle Status In Garage:.....{3}
Vehicle Model:................{4}", plateNumber, GM.GetOwnerName(plateNumber), GM.GetOwnerPhoneNumber(plateNumber), GM.GetCarState(plateNumber), GM.GetVehicleModel(plateNumber));

            VehicleWheels = GM.GetListOfWheels(plateNumber);

            for (int i = 0; i < VehicleWheels.Count; i++)
            {
                System.Console.WriteLine("Wheel {0}:......................Manufacturer: {1}, Pressure: {2}", i, VehicleWheels[i].NameOfManufacturer, VehicleWheels[i].CurrentAirPressure);
            }

            if (GM.IsVehicleRunOnFuel(plateNumber))
            {
                System.Console.WriteLine(@"Fuel Pressent:................{0}%
Fuel Kind:....................{1}", GM.GetEnergyPressent(plateNumber), GM.GetFuelKind(plateNumber));
            }

            else
            {
                System.Console.WriteLine("Battery Pressent:.............{0}%", GM.GetEnergyPressent(plateNumber));
            }

            object[]         VehicleFeatures = GM.GetVehicleFeatures(plateNumber);
            eKindsOfVehicles typeOfVehicle   = GM.GetTypeOfVehicle(plateNumber);

            if (typeOfVehicle == eKindsOfVehicles.Car)
            {
                System.Console.WriteLine(@"Car Color:....................{0} 
Car Number Of Doors:..........{1}", VehicleFeatures[0], VehicleFeatures[1]);
            }

            else if (typeOfVehicle == eKindsOfVehicles.MotorCycle)
            {
                System.Console.WriteLine(@"MotorCycle Engine Valume:.....{0}
MotorCycle Licenes:...........{1}", VehicleFeatures[0], VehicleFeatures[1]);
            }

            else
            {
                if ((bool)VehicleFeatures[0] == false)
                {
                    VehicleFeatures[0] = "No";
                }

                else
                {
                    VehicleFeatures[0] = "Yes";
                }

                System.Console.WriteLine(@"Truck Have A Freige:..........{0}, 
Capacity Of Storage Licenes:..{1}", VehicleFeatures[0], VehicleFeatures[1]);
            }
        }
Exemplo n.º 6
0
        private void CreateNewVehicle(string i_PlateNumber)//continue of function 1
        {
            eKindsOfVehicles eKindOfVehicle = 0;
            string           ownerName;
            string           ownerPhoneNumber;
            string           modelName;
            string           inputString;
            float            currentEnergyCapacity = 0;
            float            MaxEnergyCapacityForVehicle;

            object[] GeneralParamsOfVehicle = new object[6];

            GeneralParamsOfVehicle[0] = i_PlateNumber;
            System.Console.WriteLine("Please Insert the Vehicle's Owner Name: ");
            ownerName = System.Console.ReadLine();
            while (!IV.ValidInputIsNotEmpty(ownerName))
            {
                ownerName = System.Console.ReadLine();
            }

            GeneralParamsOfVehicle[1] = ownerName;
            System.Console.WriteLine("Please Insert the Vehicle's Owner Phone Number: ");
            ownerPhoneNumber = System.Console.ReadLine();
            while (!IV.ValidInputIsNotEmpty(ownerPhoneNumber))
            {
                ownerPhoneNumber = System.Console.ReadLine();
            }
            GeneralParamsOfVehicle[2] = ownerPhoneNumber;

            System.Console.WriteLine(@"Please Choose Witch kind Of Vehicle Do You Want: 
[Car(1) /Electronic Car(2) /MotorCycle(3) /Electronic MotorCycle(4) /Truck(5)]");
            inputString = System.Console.ReadLine();
            while (!IV.ValidInputKindOfVehicle(inputString, ref eKindOfVehicle))
            {
                inputString = System.Console.ReadLine();
            }

            GeneralParamsOfVehicle[3] = eKindOfVehicle;

            System.Console.WriteLine("Please Insert The Model Name Of The Vehicle: ");
            modelName = System.Console.ReadLine();
            while (!IV.ValidInputIsNotEmpty(modelName))
            {
                modelName = System.Console.ReadLine();
            }

            GeneralParamsOfVehicle[4]   = modelName;
            MaxEnergyCapacityForVehicle = GM.GetMaxCapacityForVehicle(eKindOfVehicle);
            System.Console.WriteLine("Please Insert the Vehicle's current Energy Capacity [Max {0}]: ", MaxEnergyCapacityForVehicle);
            inputString = System.Console.ReadLine();
            while (!IV.ValidInputCurrentEnergyCapacity(inputString, eKindOfVehicle, ref currentEnergyCapacity, MaxEnergyCapacityForVehicle))
            {
                inputString = System.Console.ReadLine();
            }

            GeneralParamsOfVehicle[5] = currentEnergyCapacity;

            if (eKindOfVehicle == eKindsOfVehicles.Car || eKindOfVehicle == eKindsOfVehicles.ElectronicCar)
            {
                CreatCar(GeneralParamsOfVehicle, i_PlateNumber);
            }
            else if (eKindOfVehicle == eKindsOfVehicles.MotorCycle || eKindOfVehicle == eKindsOfVehicles.ElectronicMotorCycle)
            {
                CreatMotorCycle(GeneralParamsOfVehicle, i_PlateNumber);
            }
            else if (eKindOfVehicle == eKindsOfVehicles.Truck)
            {
                CreatTruck(GeneralParamsOfVehicle, i_PlateNumber);
            }
        }