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

📄 questioncontainer.cs

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

namespace ExaminationSystem.BLL.Domain
{
    public class QuestionContainer:DomainObject<long>
    {
        private string title;

        public virtual string Title
        {
            get { return title; }
            set { title = value; }
        }
        public virtual int ScoreValue
        {
            get 
            {
                int scoreValue = 0;
                foreach (Question q in Questions)
                    scoreValue += q.ScoreValue;
                return scoreValue;
            }
        }
        public virtual int Score
        {
            get
            {
                int score = 0;
                foreach (Question q in Questions)
                    score += q.Score;
                return score;
            }
        }
        public virtual int Count
        {
            get { return Questions.Count; }
        }
        private IList<Question> questions = new List<Question>();

        public virtual IList<Question> Questions
        {
            get { return questions; }
            set { questions = value; }
        }
        public override int GetHashCode()
        {
            return (GetType().FullName + "|" +
                Title).GetHashCode(); ;
        }
        public string GetContainerXML()
        {
            StringBuilder builder = new StringBuilder(500);
            builder.Append("<QuestionContainer Title=\"" + Title + "\" ScoreValue=\"" + ScoreValue + "\" Score=\"" + Score + "\" Count=\"" + Count + "\">");
            foreach (Question q in Questions)
                builder.Append(q.GetQuestionXML());
            builder.Append("</QuestionContainer>");

            return builder.ToString();
        }
        private Paper paper;

        public virtual Paper Paper
        {
            get { return paper; }
            set { paper = value; }
        }
        public void AddQuestion(Question question)
        {
            Questions.Add(question);
            question.QuestionContainer = this;
        }
        public bool IsScored
        {
            get {
                foreach (Question q in Questions)
                {
                    if (q.IsScored == false)
                        return false;
                }
                return true;
            }
        }
    }
}

⌨️ 快捷键说明

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