Example #1
0
        // (1) To add new vehicle to the garage and to check if he allready inside.
        public void AddVehicle(string i_LicenseNumber, string i_VehicleOwnerName, string i_VehicleOwnerPhone, Vehicle i_Vehicle)
        {
            VehicleStatusInfo newVehicle = new VehicleStatusInfo(i_LicenseNumber, i_VehicleOwnerName, i_LicenseNumber, i_Vehicle);

            m_VehiclesList.Add(newVehicle);
            m_NumberOfVehicles++;
        }
Example #2
0
        // Takeing a vehicle license number and creating a new vehicleStatusInfo.
        public VehicleStatusInfo GetNewVehicleStatusInfo(string i_LicenseNumber)
        {
            eVehicleType vehicleType       = GetVehicleType();
            string       vehicleOwnerName  = GetVehicleOwnerName();
            string       vehicleOwnerPhone = GetVehicleOwnerPhone();
            string       modelName         = GetVehicleModleName();
            eEnergyType  energyType        = getEnergyInput(vehicleType);
            float        maxEnergy         = GetMaxEnergy(vehicleType);
            float        energyLeft        = ChooseNumOf(energyType + " Left in the vehicle (float)", 0, maxEnergy);
            List <Wheel> wheelList         = GetWheelList(vehicleType);
            Vehicle      newVehicle;

            switch (vehicleType)
            {
            case eVehicleType.MotoricCar:
                eColor motorCarcolor      = GetColor();
                int    motorCarNumOfDoors = GetNumOfDoors();
                newVehicle = new Car(modelName, i_LicenseNumber, energyLeft, wheelList, energyType, maxEnergy, motorCarcolor, motorCarNumOfDoors);
                break;

            case eVehicleType.ElectricCar:
                eColor elctCarColor      = GetColor();
                int    elctCarNumOfDoors = GetNumOfDoors();
                newVehicle = new Car(modelName, i_LicenseNumber, energyLeft, wheelList, energyType, maxEnergy, elctCarColor, elctCarNumOfDoors);
                break;

            case eVehicleType.MotoricBike:
                eLisenceSize licenseSize    = GetLicenseSize();
                int          engineCapacity = GetEngineCapacity();
                newVehicle = new Motorcycle(modelName, i_LicenseNumber, energyLeft, wheelList, energyType, maxEnergy, licenseSize, engineCapacity);
                break;

            case eVehicleType.ElecticBike:
                eLisenceSize elctLicenseSize    = GetLicenseSize();
                int          elctEngineCapacity = GetEngineCapacity();
                newVehicle = new Motorcycle(modelName, i_LicenseNumber, energyLeft, wheelList, energyType, maxEnergy, elctLicenseSize, elctEngineCapacity);
                break;

            case eVehicleType.Truck:
                bool  hasDangerouseMaterial = IsDangerouse();
                float maxWeight             = ChooseNumOf("max weight of the truck");
                newVehicle = new Truck(modelName, i_LicenseNumber, energyLeft, wheelList, energyType, maxEnergy, hasDangerouseMaterial, maxWeight);
                break;

            default:
                newVehicle = new Vehicle(modelName, i_LicenseNumber, energyLeft, wheelList, energyType, maxEnergy);
                break;
            }

            VehicleStatusInfo newVehicleStatusInfo = new VehicleStatusInfo(i_LicenseNumber, vehicleOwnerName, vehicleOwnerPhone, newVehicle);

            return(newVehicleStatusInfo);
        }
Example #3
0
        // (7)  Print vehicle information and status using reflection(part of didnt work on wheels).
        public void PrintVehicleInfo(string i_LicenseNumber)
        {
            VehicleStatusInfo vehicleStatusInfo = this.VehicleList[IndexOfVehicle(i_LicenseNumber)];
            Type typeOfVehicleStatusInfo        = vehicleStatusInfo.GetType();

            FieldInfo[] fieldsOfVehicleStatusInfo = typeOfVehicleStatusInfo.GetFields();
            Console.WriteLine(vehicleStatusInfo.Vehicle.GetType().Name + " full information and status:");
            Console.WriteLine(" Vehicle Owner Name: " + vehicleStatusInfo.VehicleOwnerName);
            Console.WriteLine(" Vehicle Owner Phone Number: " + vehicleStatusInfo.VehicleOwnerPhone);
            Vehicle vehicle = vehicleStatusInfo.Vehicle;

            FieldInfo[] fieldsOfVehicle = vehicle.GetType().GetFields();
            foreach (FieldInfo field in fieldsOfVehicle)
            {
                if (field.Name.Equals("m_WheelsList"))
                {
                    int counter = 1;
                    foreach (Wheel wheel in vehicle.WheelsList)
                    {
                        Console.WriteLine(" Wheel No." + counter + " information:");
                        Console.WriteLine("  Manufacture:" + wheel.Manufacture);
                        Console.WriteLine("  Max possible pressure:" + wheel.MaxPossiblePressure);
                        Console.WriteLine("  Current air pressure:" + wheel.AirPressure);
                        counter++;

                        /*
                         * FieldInfo[] fieldsOfWheel = wheel.GetType().GetFields();
                         * foreach (FieldInfo wheelField in fieldsOfWheel)
                         * {
                         *  Console.WriteLine("  " + wheelField.Name.Substring(2) + ":" + wheelField.GetValue(wheel));
                         * }*/
                    }
                }
                else
                {
                    Console.WriteLine(" " + field.Name.Substring(2) + ": " + field.GetValue(vehicle));
                }
            }
        }