question.cs

来自「本在线考试系统采用了面向对象的分析和设计」· CS 代码 · 共 75 行

CS
75
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace ExaminationSystem.BLL.Domain
{
    public class Question:DomainObject<long>
    {
        private int scoreValue;

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

        private int score;

        public virtual int Score
        {
            get { return score; }
            set {
                if (value > ScoreValue)
                    throw new Exception("得分不能超过分值!");
                score = value;
            }
        }

        private string studentAnswer;

        public virtual string StudentAnswer
        {
            get { return studentAnswer; }
            set { studentAnswer = value; }
        }

        private QuestionContent content;

        public virtual QuestionContent Content
        {
            get { return content; }
            set { content = value; }
        }

        public string GetQuestionXML()
        {
            StringBuilder builder = new StringBuilder(500);
            builder.Append("<Question ID=\"" + ID + "\" ScoreValue=\"" + ScoreValue + "\"  Score=\"" + Score + "\" IsScored=\""+IsScored+"\">");
            builder.Append("<StudentAnswer><![CDATA[" + StudentAnswer + "]]></StudentAnswer>");
            builder.Append(Content.GetContentXML());
            builder.Append("</Question>");
            return builder.ToString();
        }
        public override int GetHashCode()
        {
            return (this.GetType().FullName + "|" +
                Content.GetHashCode()).GetHashCode();
        }
        private QuestionContainer questionContainer;

        public virtual QuestionContainer QuestionContainer
        {
            get { return questionContainer; }
            set { questionContainer = value; }
        }
        private bool isScored=false;

        public virtual bool IsScored
        {
            get { return isScored; }
            set { isScored = value; }
        }
    }
}

⌨️ 快捷键说明

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