Beispiel #1
0
        public int CompareTo(Car other)
        {
            if ((other == null) || !this.GetType().Equals(other.GetType()))
            {
                return(1);
            }

            Car car = other as Car;

            if (car == null)
            {
                throw new ArgumentException("Object is not a Temperature");
            }
            else
            {
                switch (car.Compare)
                {
                case CompareBy.CCM:
                    return(CCM.CompareTo(car.CCM));

                case CompareBy.Cylinder:
                    return(Cylinder.CompareTo(car.Cylinder));

                case CompareBy.Power:
                    return(Power.CompareTo(car.Power));

                case CompareBy.RPM:
                    return(RPM.CompareTo(car.RPM));

                case CompareBy.UpToHundred:
                    return(UpToHundred.CompareTo(car.UpToHundred));

                default:
                    return(MaxSpeed.CompareTo(car.MaxSpeed));    // Max Speed is default
                }
            }
        }