⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strategyitem.cs

📁 本在线考试系统采用了面向对象的分析和设计
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using ExaminationSystem.BLL.Utils;

namespace ExaminationSystem.BLL.Domain
{
    public class StrategyItem:DomainObject<long>
    {
        private IList<QuestionContent> questionContents = new List<QuestionContent>();
        private string name;

        public virtual string Name
        {
            get { return name; }
            set { name = value; }
        }
        public bool HasQuestion(QuestionContent question)
        {
            if (QuestionContents.Contains(question))
                return true;
            else
                return false;
        }

        public virtual IList<QuestionContent> QuestionContents
        {
            get { return questionContents; }
            set { questionContents = value; }
        }
        private int scoreValue;

        public virtual int ScoreValue
        {
            get { return scoreValue; }
            set { scoreValue = value; }
        }
        private int count;

        public int Count
        {
            get { return count; }
            set 
            {
                //if (value >= QuestionContents.Count)
                //    throw new Exception("count必需不能大于备选数量");
                count = value;
            }
        }
        public IList<Question> GetQuestions()
        {
            IList<Question> result = new List<Question>();

            IList<int> sourceList = new List<int>();
            for (int i = 0; i < QuestionContents.Count; i++)
                sourceList.Add(i);

            IList<int> resultList = RandomNumberHelper.RandomSelect(sourceList, count);

            foreach (int i in resultList)
            {
                Question question = new Question();
                question.Content = QuestionContents[i];
                question.ScoreValue = ScoreValue;
                result.Add(question);
            }
            return result;
        }
        private StrategyContainer strategyContainer;

        public virtual StrategyContainer StrategyContainer
        {
            get { return strategyContainer; }
            set { strategyContainer = value; }
        }
        public override int GetHashCode()
        {
            return (GetType().FullName + "|" +
                QuestionContents.GetHashCode()).GetHashCode();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -