Esempio n. 1
0
        public Vehicle ValidateExtraDataForVehicleType(CreateNewVehicle i_Factory, eVehicleType i_VehicleType)
        {
            List <string> extraData      = new List <string>();
            Vehicle       currentVehicle = null;
            bool          correctInput   = false;

            while (!correctInput)
            {
                correctInput = true;
                extraData    = i_Factory.GetExtraData(i_VehicleType);
                Console.WriteLine("Enter additional information about your " + i_VehicleType);
                for (int i = 0; i < extraData.Count; i++)
                {
                    Console.WriteLine("Enter " + extraData[i].ToLower());
                    extraData[i] = Console.ReadLine();
                }

                try
                {
                    currentVehicle = i_Factory.FinishProduction(extraData);
                }
                catch (FormatException e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine("Try again");
                    correctInput = false;
                }
            }

            return(currentVehicle);
        }
 public static Vehicle GetNewMotorcycle(
     ref Client i_Owner,
     Vehicle.VehicleType i_VehicleType,
     string i_VehicleModel,
     string i_VehicleLicenseNumber,
     ref EnergySystem i_VehicleEnergySystem,
     short i_WheelsNumber,
     ref List <Wheel> i_VehicleWheels)
 {
     additionalMotorcycleInformationLabel();
     return(CreateNewVehicle.CreateNewMotorcycle(
                ref i_Owner,
                i_VehicleType,
                i_VehicleModel,
                i_VehicleLicenseNumber,
                ref i_VehicleEnergySystem,
                i_WheelsNumber,
                ref i_VehicleWheels,
                getEngineCapacity(),
                getLicenseType()));
 }
Esempio n. 3
0
 public static Vehicle GetNewCar(
     ref Client i_Owner,
     Vehicle.VehicleType i_VehicleType,
     string i_VehicleModel,
     string i_VehicleLicenseNumber,
     ref EnergySystem i_VehicleEnergySystem,
     short i_WheelsNumber,
     ref List <Wheel> i_VehicleWheels)
 {
     additionalCarInformationLabel();
     return(CreateNewVehicle.CreateNewCar(
                ref i_Owner,
                i_VehicleType,
                i_VehicleModel,
                i_VehicleLicenseNumber,
                ref i_VehicleEnergySystem,
                i_WheelsNumber,
                ref i_VehicleWheels,
                getCarColor(),
                getCarDoors()));
 }
 public static Vehicle GetNewTruck(
     ref Client i_Owner,
     Vehicle.VehicleType i_VehicleType,
     string i_VehicleModel,
     string i_VehicleLicenseNumber,
     ref EnergySystem i_VehicleEnergySystem,
     short i_WheelsNumber,
     ref List <Wheel> i_VehicleWheels)
 {
     additionalTruckInformationLabel();
     return(CreateNewVehicle.CreatNewTruck(
                ref i_Owner,
                i_VehicleType,
                i_VehicleModel,
                i_VehicleLicenseNumber,
                ref i_VehicleEnergySystem,
                i_WheelsNumber,
                ref i_VehicleWheels,
                getcargoVolume(),
                cargoDangerousMaterials()));
 }
        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();
        }
Esempio n. 6
0
        private void insertNewVehicleToGarage(string i_LicenseNumber)
        {
            string ownerName        = this.inputFromUser("Enter owner's name:");
            string ownerPhoneNumber = this.PhoneNumberFromUser();
            string modelName        = string.Empty;
            string wheelProducer    = string.Empty;
            float  energyLevel      = 0;
            float  wheelAirPressure = 0;
            int    engineCapacity   = 0;

            Vehicle.eCarColors      color;
            Vehicle.eCarDoorsAmount door;
            Vehicle.eLicenseTypes   LicenseType;
            Engine       engine  = null;
            List <Wheel> wheels  = null;
            Vehicle      vehicle = null;
            Dictionary <string, object> features = new Dictionary <string, object>();

            Console.WriteLine();
            string vehicleTypeMsg = string.Format(
                @"Choose vehicle type:
1) Gas car.
2) Electric car.
3) Gas motorcycle.
4) Electric motorcycle.
5) Truck.");

            Console.WriteLine(vehicleTypeMsg);
            Vehicle.eVehicleTypes vehicleType = (Vehicle.eVehicleTypes)inputFromUserAndCheckIfInRangeInt(1, 5);
            modelName     = inputFromUser("Insert the " + vehicleType + " Model name:");
            wheelProducer = inputFromUser("Insert wheels producer:");
            switch (vehicleType)
            {
            case Vehicle.eVehicleTypes.GasCar:
                Console.WriteLine("Insert current fuel level:");
                energyLevel = inputFromUserAndCheckIfInRangeFloat(0, 42.0f);
                Console.WriteLine("Insert current wheel air pressure:");
                wheelAirPressure = inputFromUserAndCheckIfInRangeFloat(0, 30.0f);
                color            = (Vehicle.eCarColors)inputCarColor();
                features.Add("i_CarColor", color);
                door = (Vehicle.eCarDoorsAmount)inputNumberOfCarDoors();
                features.Add("i_CarDoors", door);
                break;

            case Vehicle.eVehicleTypes.ElectricCar:
                Console.WriteLine("Insert current battery level:");
                energyLevel = inputFromUserAndCheckIfInRangeFloat(0, 2.5f);
                Console.WriteLine("Insert current wheel air Pressure:");
                wheelAirPressure = inputFromUserAndCheckIfInRangeFloat(0, 30.0f);
                color            = (Vehicle.eCarColors)inputCarColor();
                features.Add("i_CarColor", color);
                door = (Vehicle.eCarDoorsAmount)inputNumberOfCarDoors();
                features.Add("i_CarDoors", door);
                break;

            case Vehicle.eVehicleTypes.GasMotorcycle:
                Console.WriteLine("Insert current fuel level:");
                energyLevel = inputFromUserAndCheckIfInRangeFloat(0, 5.5f);
                Console.WriteLine("Insert wheel air pressure:");
                wheelAirPressure = inputFromUserAndCheckIfInRangeFloat(0, 33.0f);
                LicenseType      = (Vehicle.eLicenseTypes)inputMotorcycleLicenseType();
                features.Add("i_MotorcycleLicenseType", LicenseType);
                Console.WriteLine("Insert engine capacity:");
                engineCapacity = inputFromUserAndCheckIfInRangeInt(0, 3000);
                features.Add("i_EngineCapacity", engineCapacity);
                break;

            case Vehicle.eVehicleTypes.ElectricMotorcycle:
                Console.WriteLine("Insert current battery level:");
                energyLevel = inputFromUserAndCheckIfInRangeFloat(0, 2.7f);
                Console.WriteLine("Insert current wheel air pressure:");
                wheelAirPressure = inputFromUserAndCheckIfInRangeFloat(0, 33.0f);
                LicenseType      = (Vehicle.eLicenseTypes)inputMotorcycleLicenseType();
                features.Add("i_MotorcycleLicenseType", LicenseType);
                Console.WriteLine("Insert engine capacity:");
                engineCapacity = inputFromUserAndCheckIfInRangeInt(0, 3000);
                features.Add("i_EngineCapacity", engineCapacity);
                break;

            case Vehicle.eVehicleTypes.Truck:
                Console.WriteLine("Insert current fuel level:");
                energyLevel = inputFromUserAndCheckIfInRangeFloat(0, 135.0f);
                Console.WriteLine("Insert current wheel air pressure:");
                wheelAirPressure = inputFromUserAndCheckIfInRangeFloat(0, 32.0f);
                string chooseIfCarryingDangerousMaterials = string.Format(
                    @"Choose if the truck is carrying dangerous materials:
1) Yes.
2) No.");
                Console.WriteLine(chooseIfCarryingDangerousMaterials);
                bool isCarryingDangerousMaterials = inputFromUserAndCheckIfInRangeInt(1, 2) == 1;
                features.Add("i_IsCarryingDangerousMaterials", isCarryingDangerousMaterials);
                Console.WriteLine("Insert maximum carrying Weight:");
                float maxCarryingWeight = inputFromUserAndCheckIfInRangeFloat(0, 60000);
                features.Add("i_MaximumCarryingWeight", maxCarryingWeight);
                break;
            }

            engine = CreateNewVehicle.CreateEngine(vehicleType, energyLevel);
            wheels = CreateNewVehicle.NewWheels(vehicleType, wheelProducer, wheelAirPressure);
            try
            {
                vehicle = CreateNewVehicle.CreateVehicle(vehicleType, modelName, i_LicenseNumber, energyLevel, wheels, engine, features);
                m_Garage.InsertVehicleToTheGarage(ownerName, ownerPhoneNumber, vehicle);
                Console.WriteLine("New vehicle was added succesfully!");
            }
            catch
            {
                Console.WriteLine("There was a problem while trying to insert the vehicle to the garage, please try again!");
            }
        }