public override int CompareTo(QuestionContentPart other)
        {
            if (this == other)
            {
                return(0);
            }

            if (!(other is ArithmeticDecimalValuePart))
            {
                return(-1);
            }

            ArithmeticDecimalValuePart valuePart = other as ArithmeticDecimalValuePart;

            if (this.Value == valuePart.value)
            {
                return(0);
            }
            else if (this.value > valuePart.value)
            {
                return(1);
            }

            return(-1);
        }
Beispiel #2
0
        internal static IEnumerable <ArithmeticDecimalValuePart> CreateIntergetValue(int minValue, int maxValue)
        {
            Random rand  = new Random(Environment.TickCount);
            int    value = rand.Next(minValue, maxValue + 1);
            ArithmeticDecimalValuePart valuePart = new ArithmeticDecimalValuePart(value);

            yield return(valuePart);
        }
        public override object Clone()
        {
            ArithmeticDecimalValuePart newPart = new ArithmeticDecimalValuePart();

            newPart.Id    = this.Id;
            newPart.Value = new decimal?(this.Value.Value);

            return(newPart);
        }
Beispiel #4
0
        private static IEnumerable <ArithmeticDecimalValuePart> CreateDoubleValue(int leftMinValue, int leftMaxValue, int rightMinValue, int rightMaxValue)
        {
            Random rand     = new Random(Environment.TickCount);
            int    partLeft = rand.Next(leftMinValue, leftMaxValue + 1);

            Thread.Sleep(50);
            int    partRight = rand.Next(rightMinValue, rightMaxValue + 1);
            double value     = Convert.ToDouble(string.Format("{0}.{1}", partLeft, partRight));
            ArithmeticDecimalValuePart valuePart = new ArithmeticDecimalValuePart(new decimal(value));

            yield return(valuePart);
        }
Beispiel #5
0
        internal static IEnumerable <QuestionOption> CreateDoubleOption(int leftMinValue, int leftMaxValue, int rightMinValue, int rightMaxValue)
        {
            ArithmeticDecimalValuePart decimalValue = null;

            foreach (ArithmeticDecimalValuePart value in CreateDoubleValue(leftMinValue, leftMaxValue, rightMinValue, rightMaxValue))
            {
                decimalValue = value;
            }

            QuestionOption option = new QuestionOption();

            option.OptionContent.Content     = decimalValue.PlaceHolder;
            option.OptionContent.ContentType = ContentType.Text;
            option.OptionContent.QuestionPartCollection.Add(decimalValue);

            yield return(option);
        }