internal static void GarageSystem()
        {
            Ex03.GarageLogic.Garage myGarage = new Ex03.GarageLogic.Garage();

            string helloMassage = string.Format(
                @"Welcome to garage manager!
Please select the action you want:

1. Add new vehicle to the garage
2. Show all the vehicles in garage (by license number)
3. Change car status
4. Inflate air in the wheels of a vehicle
5. Fuel a vehicle powered by fuel
6. To charge an electric vehicle
7. Show full details of a vehicle

enter the number of action");

            Console.WriteLine(helloMassage);
            string selectionString = Console.ReadLine();
            int    actionNumber    = validateMenuSelection(selectionString);

            switch (actionNumber)
            {
            case 1:
                addNewVehicle(myGarage);
                break;

            case 2:
                showAllVehiclesLicenses(myGarage);
                break;

            case 3:
                changeCarStatus(myGarage);
                break;

            case 4:
                inflateAirToVehicle(myGarage);
                break;

            case 5:
                refuelVehicle(myGarage);
                break;

            case 6:
                rechargeVehicle(myGarage);
                break;

            case 7:
                showAllDetailsOfVehicle(myGarage);
                break;
            }
        }
示例#2
0
        public static float GetCurrentAirPressure(int i_TypeOfCar, Garage s_Garage)
        {
            float maxAirPressure = 0;

            switch (i_TypeOfCar)
            {
            case 1:
            case 2:
                maxAirPressure = s_Garage.MaxAirPressureCar;
                break;

            case 3:
            case 4:
                maxAirPressure = s_Garage.MaxAirPressureMotorcycle;
                break;

            case 5:
                maxAirPressure = s_Garage.MaxAirPressureTruck;
                break;
            }

            return(GetFloatValueInRange(0, maxAirPressure));
        }
示例#3
0
        internal static void AddBike(Garage i_Garage, string i_OwnerName, string i_PhoneNumber, Dictionary <string, object> i_VehicleDetails, Dictionary <string, object> i_SpecialDict)
        {
            GarageENum.eAcceptedVehicleTypes type = (GarageENum.eAcceptedVehicleTypes)i_VehicleDetails["Energy type"];
            Bike newBike = null;

            i_VehicleDetails["Max wheels pressure"] = k_BikeMaxWheelAirPressure;
            switch (type)
            {
            case GarageENum.eAcceptedVehicleTypes.FuelBike:
                i_VehicleDetails["Max energy"]  = k_BikeMaxFuelLevel;
                i_VehicleDetails["Energy type"] = GarageENum.eEnergyType.Octan96;
                newBike = new Bike(i_VehicleDetails, i_SpecialDict);
                break;

            case GarageENum.eAcceptedVehicleTypes.ElectricBike:
                i_VehicleDetails["Max energy"]  = k_BikeMaxBatteryLevel;
                i_VehicleDetails["Energy type"] = GarageENum.eEnergyType.Electric;
                newBike = new Bike(i_VehicleDetails, i_SpecialDict);
                break;
            }

            i_Garage.AddVehicle(new VehicleInGarage(newBike, i_OwnerName, i_PhoneNumber, (GarageENum.eEnergyType)i_VehicleDetails["Energy type"]));
        }
示例#4
0
        public static bool CheckProperty(Garage i_Garage, string i_Value, string i_Field, string i_Type)
        {
            bool         boolField        = false;
            string       stringField      = "";
            float        floatField       = 0;
            int          intField         = 0;
            eCarDoors    doorField        = eCarDoors.Five;
            eColor       colorField       = eColor.Black;
            eLicenseType licenseTypeField = eLicenseType.A;
            string       colorError       = "This Field must be one of those: " + String.Join(" / ", Enum.GetNames(typeof(eColor)).ToList().Select(x => x.ToString()));
            string       carDoorError     = "This Field must be one of those: " + String.Join(" / ", Enum.GetNames(typeof(eCarDoors)).ToList().Select(x => x.ToString()));
            string       licenseTypeError = "This Field must be one of those: " + String.Join(" / ", Enum.GetNames(typeof(eLicenseType)).ToList().Select(x => x.ToString()));

            switch (i_Type)
            {
            case "int":
                intField = !int.TryParse(i_Value, out intField) ?
                           throw new FormatException("This Field must be a number") :
                                 intField < 0 ? throw new FormatException("Positive number only") : intField;
                break;

            case "eColor":
                colorField = !Enum.IsDefined(typeof(eColor), i_Value) ?
                             throw new FormatException(colorError) : colorField;
                break;

            case "eCarDoors":
                doorField = !Enum.IsDefined(typeof(eCarDoors), i_Value) ?
                            throw new FormatException(carDoorError) : doorField;
                break;

            case "eLicenseType":
                licenseTypeField = !Enum.IsDefined(typeof(eLicenseType), i_Value) ?
                                   throw new FormatException(licenseTypeError) : licenseTypeField;
                break;

            case "bool":
                boolField = !bool.TryParse(i_Value, out boolField) ? throw new FormatException("This Field must be a True of False") : boolField;
                break;

            case "float":
                floatField = !float.TryParse(i_Value, out floatField) ?
                             throw new FormatException("This Field must be a float") :
                                   floatField < 0 ? throw new FormatException("Positive number only") : floatField;
                break;

            case "string":
                if (i_Field == "License Plate")
                {
                    if (i_Garage.IsLicensePlateExists(i_Value))
                    {
                        throw new ArgumentException("There is already a Vehicle with the same license plate");
                    }
                }
                if (i_Value.Replace(" ", "").Length == 0)
                {
                    throw new FormatException("This Field can't be empty");
                }

                break;
            }

            return(true);
        }
示例#5
0
        public static Vehicle CreateNewVehicle(Garage i_Garage, eVehicleTypes vehicleType, Dictionary <string, string> i_Properties)
        {
            Vehicle      i_Vehicle;
            bool         creationSuccess = false;
            string       modelName = "", licensePlate = "", manufacture = "";
            float        engineCapacity = 0, loadVolume = 0;
            bool         isCarryingDangerousLoad = false;
            eCarDoors    door        = eCarDoors.Five;
            eColor       color       = eColor.Black;
            eLicenseType licenseType = eLicenseType.A;

            foreach (KeyValuePair <string, string> pairs in i_Properties)
            {
                switch (pairs.Key)
                {
                case "Model Name":
                    modelName = pairs.Value;
                    break;

                case "License Plate":
                    licensePlate = pairs.Value;
                    break;

                case "Manufacture":
                    manufacture = pairs.Value;
                    break;

                case "Car Color":
                    eColor.TryParse(pairs.Value, out color);
                    break;

                case "Number of Doors":
                    eCarDoors.TryParse(pairs.Value, out door);
                    break;

                case "Engine Capacity CCS":
                    engineCapacity = float.Parse(pairs.Value);
                    break;

                case "License Type":
                    eLicenseType.TryParse(pairs.Value, out licenseType);
                    break;

                case "Is carrying dangerous load":
                    isCarryingDangerousLoad = bool.Parse(pairs.Value);
                    break;

                case "Load Volume":
                    loadVolume = float.Parse(pairs.Value);
                    break;
                }
            }

            switch (vehicleType)
            {
            case eVehicleTypes.ElectronicCar:
                i_Vehicle = new ElectricCar(modelName, licensePlate, color, door, manufacture);
                //ElectricCar.TryParse(i_Properties, out newVehicle);
                break;

            case eVehicleTypes.ElectronicMotorCycle:
                i_Vehicle = new ElectricMotorCycle(modelName, licensePlate, engineCapacity, eLicenseType.A1, manufacture);
                break;

            case eVehicleTypes.FuelCar:
                i_Vehicle = new FuelCar(modelName, licensePlate, color, door, manufacture);
                //FuelCar.TryParse(i_Properties, out newVehicle);
                break;

            case eVehicleTypes.FuelMotorCycle:
                i_Vehicle = new FuelMotorCycle(modelName, licensePlate, engineCapacity, licenseType, manufacture);
                break;

            case eVehicleTypes.Truck:
                i_Vehicle = new Truck(modelName, licensePlate, manufacture, isCarryingDangerousLoad, loadVolume);
                break;

            default:
                i_Vehicle = null;
                break;
            }
            return(i_Vehicle);
        }
示例#6
0
 public static void RunGarageSystem()
 {
     m_Garage = new Garage();
 }
 public GarageManager()
 {
     m_Garage = new Garage();
 }