Exemplo n.º 1
0
        public void StoreVehicle(Vehicle i_VehicleToStore, VehicleOwner i_OwnerToStore)
        {
            StoredVehicle newVehicle = new StoredVehicle(i_VehicleToStore, i_OwnerToStore);
            bool          isVehicleIdAlreadyRegistered = false;

            isVehicleIdAlreadyRegistered = m_StoredVehiclesDictionary.ContainsKey(i_VehicleToStore.GetHashCode());
            if (isVehicleIdAlreadyRegistered)
            {
                throw new ArgumentException(string.Format("ID: {0} is already registered.", i_VehicleToStore.ID));
            }

            m_StoredVehiclesDictionary.Add(i_VehicleToStore.GetHashCode(), newVehicle);
        }
Exemplo n.º 2
0
 public GarageVehicle(Vehicle i_NewVehicleToInsert, string i_OwnerName, string i_OwnerPhoneNumber)
 {
     if (!CurrentGarageVehicles.ContainsKey(i_NewVehicleToInsert.GetHashCode()))
     {
         m_OwnerName        = i_OwnerName;
         m_OwnerPhoneNumber = i_OwnerPhoneNumber;
         m_CarStatus        = eGarageVehicleStatus.OnRepair;
         m_Vehicle          = i_NewVehicleToInsert;
         CurrentGarageVehicles.Add(i_NewVehicleToInsert.GetHashCode(), this);
     }
     else
     {
         CurrentGarageVehicles.TryGetValue(i_NewVehicleToInsert.GetHashCode(), out GarageVehicle garageVehicle);
         garageVehicle.m_CarStatus = eGarageVehicleStatus.OnRepair;
     }
 }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            bool    equal       = false;
            Vehicle toCompareTo = obj as Vehicle;

            if (toCompareTo != null)
            {
                equal = this.GetHashCode() == toCompareTo.GetHashCode();
            }

            return(equal);
        }
        public override bool Equals(object i_obj)
        {
            Vehicle vehicleToCompare = i_obj as Vehicle;
            bool    isEqual          = false;

            if (vehicleToCompare != null)
            {
                isEqual = GetHashCode().Equals(vehicleToCompare.GetHashCode());
            }
            else
            {
                throw new ArgumentException();
            }

            return(isEqual);
        }
Exemplo n.º 5
0
        // catch exception
        public override bool Equals(object io_obj)
        {
            bool eqauls = false;

            if (io_obj != null)
            {
                Vehicle toCompareTo = io_obj as Vehicle;

                if (toCompareTo != null)
                {
                    eqauls = this.GetHashCode() == toCompareTo.GetHashCode();
                }
            }

            return(eqauls);
        }
Exemplo n.º 6
0
 public void AddVehicleToGarageSystem(Vehicle i_NewVehicleToAdd)
 {
     m_VehicleInTheGarage.Add(i_NewVehicleToAdd.GetHashCode(), i_NewVehicleToAdd);
 }
 public override int GetHashCode()
 {
     return(m_Vehicle.GetHashCode());
 }