コード例 #1
0
        public static void EnterInformation(string i_VehicleLicenseNumber, char i_VehicleType, string i_OwnerName, string i_OwnerPhoneNumber)
        {
            //// general members
            string i_VehicleModel;
            float  i_CurrentEnergyLevel;
            string i_CurrentEnergyLevelSTR;
            float  i_MaxEnergyLevel;
            char   i_FuelTypeSign;

            Engine.eFuelType i_FuelType;
            char             i_ChoosenVehicleEngineType;

            //// car members
            char i_CarColorChar;

            Car.eColorOfCar i_CarColor;
            int             i_NumberOfDoors;
            char            i_NumberOfDoorsChar;

            //// motorcycle members
            char i_MotorcycleLicenseTypeChar;

            Motorcycle.eLicenseType i_MotorcycleLicenseType;
            int    i_EngineCapacitiyCC;
            string i_EngineCapacitiyCCSTR;

            //// truck members
            bool   i_TrunkIsCool;
            char   i_TrunkIsCoolChar;
            float  i_TrunkCapacityCC;
            string i_TrunkCapacitySTR;

            //// play with functions
            OutPutMessages.VehicleModelDisplayMenu();
            i_VehicleModel = Console.ReadLine();
            OutPutMessages.ChooseEngineTypeDisplayMenu();
            i_ChoosenVehicleEngineType = Console.ReadKey().KeyChar;
            while (i_ChoosenVehicleEngineType != Constants.k_Fuel && i_ChoosenVehicleEngineType != Constants.k_Electric)
            {
                OutPutMessages.PrintWrongMessage();
                i_ChoosenVehicleEngineType = Console.ReadKey().KeyChar;
            }
            if (IsItAFuelEngine(i_ChoosenVehicleEngineType))
            { //// case it is a fuel engine
                OutPutMessages.ChooseFuelInVehicleTypeDisplayMenu();
                i_FuelTypeSign = Console.ReadKey().KeyChar;
                i_FuelType     = UI.GetEngineTypeFromChar(i_FuelTypeSign);
            }
            else
            { //// case it is an electric engine
                i_FuelType = Engine.eFuelType.Electricity;
            }

            OutPutMessages.VehicleEnergyLevelDisplayMenu();
            i_CurrentEnergyLevelSTR = Console.ReadLine();
            while (!(float.TryParse(i_CurrentEnergyLevelSTR, out i_CurrentEnergyLevel)))
            { //// case the string input could not convert to float
                OutPutMessages.VehicleEnergyLevelDisplayMenu();
                i_CurrentEnergyLevelSTR = Console.ReadLine();
            }

            if (i_VehicleType == Constants.k_Car)
            {
                OutPutMessages.CarColorsDisplayMenu();
                i_CarColorChar = Console.ReadKey().KeyChar;
                i_CarColor     = GetCarColorFromChar(i_CarColorChar);
                OutPutMessages.NumberOfDoorsDisplayMenu();
                i_NumberOfDoorsChar = Console.ReadKey().KeyChar;
                i_NumberOfDoors     = (i_NumberOfDoorsChar - Constants.k_ValueToDecreaseFromCharToGetInt);
                if (IsItAFuelEngine(i_ChoosenVehicleEngineType))
                { //// case it is a fuel engine
                    i_MaxEnergyLevel = Constants.k_CarFuelTankCapacity;
                }
                else
                { //// case it is an electric engine
                    i_MaxEnergyLevel = Constants.k_CarBatteryMaxHours;
                }

                CreateNewVehicle.AddNewCarCompleteInformation(i_VehicleLicenseNumber, i_VehicleModel, i_MaxEnergyLevel, i_CurrentEnergyLevel, i_CarColor, i_NumberOfDoors, i_FuelType, i_OwnerName, i_OwnerPhoneNumber);
            }
            else if (i_VehicleType == Constants.k_Motorcycle)
            {
                OutPutMessages.MotorcycleLicenseDisplayMenu();
                i_MotorcycleLicenseTypeChar = Console.ReadKey().KeyChar;
                i_MotorcycleLicenseType     = GetLicenseTypeFromChar(i_MotorcycleLicenseTypeChar);
                OutPutMessages.EngineCapacityCCDisplayMenu();
                i_EngineCapacitiyCCSTR = Console.ReadLine();
                i_EngineCapacitiyCC    = int.Parse(i_EngineCapacitiyCCSTR);
                if (IsItAFuelEngine(i_ChoosenVehicleEngineType))
                { //// case it is a fuel engine
                    i_MaxEnergyLevel = Constants.k_MotorcycleFuelTankCapacity;
                }
                else
                { //// case it is an electric engine
                    i_MaxEnergyLevel = Constants.k_MotorcycleBatteryMaxHours;
                }

                CreateNewVehicle.AddNewMotorcycleCompleteInformation(i_VehicleLicenseNumber, i_VehicleModel, i_MaxEnergyLevel, i_CurrentEnergyLevel, i_MotorcycleLicenseType, i_EngineCapacitiyCC, i_FuelType, i_OwnerName, i_OwnerPhoneNumber);
            }
            else
            { //// if (i_VehicleType == Constants.k_Truck)
                OutPutMessages.TruckDisplayMenu();
                i_TrunkCapacitySTR = Console.ReadLine();
                while (!float.TryParse(i_TrunkCapacitySTR, out i_TrunkCapacityCC))
                {
                    OutPutMessages.TruckDisplayMenu();
                    i_TrunkCapacitySTR = Console.ReadLine();
                }

                i_TrunkIsCoolChar = Console.ReadKey().KeyChar;
                i_TrunkIsCool     = IsTheTrunkIsColler(i_TrunkIsCoolChar);
                i_MaxEnergyLevel  = Constants.k_TruckFuelTankCapacity;
                CreateNewVehicle.AddNewTruckCompleteInformation(i_VehicleLicenseNumber, i_VehicleModel, i_MaxEnergyLevel, i_CurrentEnergyLevel, i_TrunkIsCool, i_TrunkCapacityCC, i_FuelType, i_OwnerName, i_OwnerPhoneNumber);
            }

            Console.Clear();
            OutPutMessages.SuccessMessageDisplayMenu();
            UI.WorkingInTheGarage();
        }