public void Button1_Click(object sender, EventArgs e)
        {
            ReturnConditions condition   = new ReturnConditions();
            bool             isException = condition.IsException(Percentage.Text);

            if (isException == false)
            {
                if (!condition.IslLegit(Percentage.Text))
                {
                    lblMessage.Text = "Enter legitimate percentage";
                }
                else
                {
                    if (condition.IsPassed(Percentage.Text))
                    {
                        lblMessage.Text = "Student Passed";
                    }
                    else
                    {
                        lblMessage.Text = "Student Failed";
                    }
                }
            }
            else
            {
                lblMessage.Text = "Only integer values allowed";
            }
        }
Esempio n. 2
0
        public bool SameObject(iFind obj, ReturnConditions conditions = ReturnConditions.WithSlash)
        {
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }

            if (obj == null)
            {
                return(false);
            }

            if (!string.Equals(Street, obj.Street, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            var sameNumber  = HomeNumber == obj.HomeNumber;
            var sameHousing = Housing == obj.Housing;
            var sameSlash   = AfterSlash == obj.AfterSlash;

            if ((conditions & ReturnConditions.SameHouse) != 0 &&
                sameNumber)
            {
                return(true);
            }

            if ((conditions & ReturnConditions.SameHousing) != ReturnConditions.SameHousing &&
                sameHousing)
            {
                return(true);
            }

            if ((conditions & ReturnConditions.WithSlash) != ReturnConditions.WithSlash &&
                sameSlash)
            {
                return(true);
            }

            //todo add more/less

            return(false);
        }
Esempio n. 3
0
        /// <summary>
        ///     Возвращает тот же дом, только не учитывает корпус
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="findCondition">Условия поиска</param>
        /// <returns></returns>
        public bool TheSameHouse(BaseFindableObject obj,
                                 ReturnConditions findCondition)
        {
            // нет объекта, ошибка
            if (obj == null)
            {
                return(false);
            }

            // улицы разные
            if (!TheSameStreet(obj.Street))
            {
                return(false);
            }

            // нашли номера домов
            var number    = new HouseNumber(HouseNumber);
            var objNumber = new HouseNumber(obj.HouseNumber);

            // разные номера, выходим
            if (number.Number != objNumber.Number)
            {
                return(false);
            }

            // нужно сравнить слеши
            if ((findCondition & ReturnConditions.CompareSlash) == ReturnConditions.CompareSlash &&
                number.AfterSlash != objNumber.AfterSlash)
            {
                return(false);
            }

            // возвращаем что угодно
            if ((findCondition & ReturnConditions.All) == ReturnConditions.All)
            {
                return(true);
            }

            // сравниваем значения
            var compare = number.Housing.CompareTo(objNumber.Housing);

            // возвращаем, если стоит включать себя
            if (compare == 0 && (findCondition & ReturnConditions.Self) == ReturnConditions.Self)
            {
                return(true);
            }

            // нашли меньше
            if (compare < 0 && (findCondition & ReturnConditions.LessThen) == ReturnConditions.LessThen)
            {
                return(true);
            }

            // нашли больше
            if (compare > 0 && (findCondition & ReturnConditions.MoreThen) == ReturnConditions.MoreThen)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
 public void TestSetup()
 {
     condition = new ReturnConditions();
 }