예제 #1
0
        public void AddVehicleToGarage(string i_Owner, string i_Phone, VehicleInputData i_VehicleData)
        {
            VehicleCard newCard, foundCard;
            Vehicle     newVehicle;

            try
            {
                foundCard = FindCardByLicense(i_VehicleData.m_LicenseNumber);
            }
            catch (KeyNotFoundException)
            {
                foundCard = null;
            }

            if (foundCard == null)
            {
                newVehicle = VehicleCreator.CreateNewVehicle(i_VehicleData);
                newCard    = new VehicleCard(i_Owner, i_Phone, VehicleCard.eVehicleStatus.InService, newVehicle);
                m_Cards.Add(newCard);
            }
            else
            {
                foundCard.Status = VehicleCard.eVehicleStatus.InService;
                throw new VehicleAllreadyInGarageException(new Exception(), foundCard.Vehicle.LicenseNumber);
            }
        }
예제 #2
0
        public void InsertNewCustomer(string i_NumberOfCarLicense, Utilities.eTypeOfVehicle i_VehicleType, string i_ModelName, string i_NameOfManufacturer, float i_CurTirePressure, string i_NameOfVehicleOwner, string i_PhoneNumber)
        {
            Vehicle  createdVehicle  = VehicleCreator.CreateVehicle(i_VehicleType, i_ModelName, i_NumberOfCarLicense, i_NameOfManufacturer, i_CurTirePressure);
            Customer createdCustomer = new Customer(createdVehicle, i_NameOfVehicleOwner, i_PhoneNumber);

            m_CustomerList.Add(createdCustomer);
        }
예제 #3
0
        public Truck(bool isElectric)
        {
            m_VehicleWheels = VehicleCreator.createWheels(k_NumberOfWheels, k_TruckMaxWheelPressure);
            m_VehicleEngine = VehicleCreator.CreateEngine(isElectric);

            PetrolEngine petrolEngine = m_VehicleEngine as PetrolEngine;

            petrolEngine.MaximumPetrolAmount = k_MaxPetrolLiterCapacity;
            petrolEngine.PetrolType          = k_PetrolType;
        }
예제 #4
0
        // Add new vehicle by type to the vehicle list, if the vehicle all ready exist, change his status to InRepair
        public void AddNewVehicle(string i_LicenseNumber, Enums.eVehicleType i_VehicleKind)
        {
            Vehicle NewVehicle;

            if (m_ListOfVehicles.ContainsKey(i_LicenseNumber))
            {
                m_ListOfVehicles[i_LicenseNumber].VehicleStatus = Enums.eVehicleStatus.InRepair;

                throw new Exception("Vehicle all ready exist, status changed to in repair");
            }
            else
            {
                NewVehicle = VehicleCreator.CreateNewVehicle(i_LicenseNumber, i_VehicleKind);
                m_ListOfVehicles.Add(i_LicenseNumber, NewVehicle);
            }
        }
예제 #5
0
        public void AddCarToGarage(string i_LicenseNumber, Dictionary <string, object> i_VehicleProperties)
        {
            if (m_VehiclesDictionary.ContainsKey(i_LicenseNumber))
            {
                m_VehiclesDictionary[i_LicenseNumber].CarStatus = eCarStatus.InRepair;
            }
            else
            {
                //calls creator, and bond the new vehicle with i_LicenseNumber
                Vehicle VehicleToAdd = VehicleCreator.CreateNewVehcile(i_VehicleProperties);

                m_VehiclesDictionary[i_LicenseNumber] = new ClientTicket(VehicleToAdd,
                                                                         (string)i_VehicleProperties[k_OwnerName],
                                                                         (string)i_VehicleProperties[k_OwnerPhoneNumber]);
            }
        }
예제 #6
0
        public void RegisterClass()
        {
            VehicleCreator.RegisterVehicles();

            if (!BsonClassMap.IsClassMapRegistered(typeof(CustomerCard)))
            {
                BsonClassMap.RegisterClassMap <CustomerCard>(cm =>
                {
                    cm.SetIdMember(cm.MapField(c => c.r_Id).SetElementName("CustomerID"));
                    cm.MapField(c => c.m_Name).SetElementName("CustomerName");
                    cm.MapField(c => c.m_Phone).SetElementName("CustomerPhone");
                    cm.MapField(c => c.m_Vehicle).SetElementName("Vehicle");
                    cm.MapField(c => c.m_VehicleState).SetElementName("VehicleState").SetSerializer(new EnumSerializer <eVehicleState>(BsonType.String));
                });
            }
        }
예제 #7
0
        public static string GetEnumFormatedString(Type i_EnumType, out int o_EnumLength)
        {
            string formatedNames = string.Empty;

            string[] enumNamesArr = VehicleCreator.GetEnumNameString(i_EnumType);
            o_EnumLength = enumNamesArr.Length;
            int count = 1;

            foreach (string enumName in enumNamesArr)
            {
                formatedNames += string.Format("{0}) {1}{2}", count, enumName, Environment.NewLine);
                count++;
            }

            return(formatedNames);
        }
예제 #8
0
        public Car(bool isElectric)
        {
            m_VehicleWheels = VehicleCreator.createWheels(k_NumberOfWheels, k_CarMaxWheelPressure);

            m_VehicleEngine = VehicleCreator.CreateEngine(isElectric);
            if (isElectric)
            {
                ElectricEngine electricEngine = m_VehicleEngine as ElectricEngine;
                electricEngine.MaximumBatteryHours = k_MaxBatteryHoursCapacity;
            }
            else
            {
                PetrolEngine petrolEngine = m_VehicleEngine as PetrolEngine;
                petrolEngine.MaximumPetrolAmount = k_MaxPetrolLiterCapacity;
                petrolEngine.PetrolType          = k_PetrolType;
            }
        }
        public void AddOrderToGarage(string i_LicenceNumber, string i_OwnerName, string i_PhoneNumber, string i_EnteredVehicleType, ref Order io_InitializedOrder)
        {
            io_InitializedOrder = new Order();

            io_InitializedOrder.OwnerName        = i_OwnerName;
            io_InitializedOrder.OwnerPhoneNumber = i_PhoneNumber;
            io_InitializedOrder.VehicleStatus    = Order.eVehicleStatus.FixingUp;
            VehicleCreator.eVehicleType enumEnteredVehicleType;
            if (!Enum.TryParse(i_EnteredVehicleType, true, out enumEnteredVehicleType))
            {
                throw new FormatException("Not valid input!");
            }

            io_InitializedOrder.TheVehicle = VehicleCreator.CreateEmptySpecificVehicleType(enumEnteredVehicleType);
            io_InitializedOrder.TheVehicle.LicenceNumber = i_LicenceNumber;
            m_OrdersDictionary.Add(i_LicenceNumber, io_InitializedOrder);
            m_FixingUpVehicles.Add(i_LicenceNumber, io_InitializedOrder);
        }
예제 #10
0
        public void InsertVehicle(string i_OwnerName, string i_OwnerPhone, eVehicleType i_VehicleType, string i_plateNumber)
        {
            bool isExist = false;

            foreach (string key in r_VehiclesStorage.Keys)
            {
                if (key == i_plateNumber)
                {
                    r_VehiclesStorage[key].Status = eVehicleStatus.InProgress;
                    throw new ArgumentException("Vehicle already in the garage! Changing vehicle status to 'In-Progress'");
                }
            }

            if (isExist == false)
            {
                Vehicle           i_NewVehicle   = VehicleCreator.CreateNewVehicle(i_VehicleType, i_plateNumber);
                GarageVehicleInfo NewVehicleData = new GarageVehicleInfo(i_OwnerName, i_OwnerPhone, i_NewVehicle);
                r_VehiclesStorage.Add(i_plateNumber, NewVehicleData);
            }
        }
예제 #11
0
 public void AddNewVehicleToGarage(string i_LicenseNumber, VehicleCreator.eVehicleType i_VehicleType)
 {
     if (r_Vehicles.ContainsKey(i_LicenseNumber))
     {
         r_Vehicles[i_LicenseNumber].VehicleStatus = Vehicle.eVehicleStatus.InRepair;
     }
     else
     {
         Vehicle newVehicle = VehicleCreator.CreateVehicle(i_LicenseNumber, i_VehicleType);
         r_Vehicles.Add(i_LicenseNumber, newVehicle);
         if (newVehicle.Engine is FuelEngine)
         {
             m_NumberOfFuelVehicles++;
         }
         else
         {
             m_NumberOfElectricVehicles++;
         }
     }
 }
예제 #12
0
        public List <QuestionAnswer> ParseInitialUserInput(List <QuestionAnswer> i_UserInput)
        {
            const int      k_PhoneNumberPlace   = 1;
            const int      k_LicenseNumberPlace = 2;
            const int      k_VehicleListPlace   = 3;
            const int      k_MinValue           = 1;
            int            userVehicle;
            int            k_MaxValue = Enum.GetNames(typeof(eKindOfVehicle)).Length;
            Vehicle        vehicle;
            eKindOfVehicle kindOfVehicle = eKindOfVehicle.ElectricCar;

            userVehicle = int.Parse(i_UserInput[k_VehicleListPlace].Answer);
            validatePhoneNumber(i_UserInput[k_PhoneNumberPlace].Answer);
            validateLicenseNumber(i_UserInput[k_LicenseNumberPlace].Answer);
            IsVehicleExists(i_UserInput[k_LicenseNumberPlace].Answer);
            IsNumInRange(k_MinValue, k_MaxValue, userVehicle, "The vehicle kind you gave ");
            kindOfVehicle = (eKindOfVehicle)userVehicle;
            vehicle       = VehicleCreator.CreateKindOfVehicle(kindOfVehicle, i_UserInput);
            m_DataBase.Add(vehicle);

            return(vehicle.GetQuestions());
        }
예제 #13
0
        public void CreateNewVehicle(string i_VehicleTypeNumber, string i_LicenseNumber, string i_OwnerName, string i_PhoneNumber)
        {
            Vehicle vehicle = VehicleCreator.CreateVehicle(i_VehicleTypeNumber, i_LicenseNumber);

            addVehicleToGarage(i_LicenseNumber, vehicle, i_OwnerName, i_PhoneNumber);
        }