Beispiel #1
0
        public void Setup()
        {
            Question q1 = new Question();
            q1.Text = "Question One";
            q1.Responses = 100;
            q1.Answers.Add(new Answer("answer 1-1", 50));
            q1.Answers.Add(new Answer("answer 1-2", 25));
            q1.Answers.Add(new Answer("answer 1-3", 25));
            Question q2 = new Question();
            q2.Text = "Question The second";
            q2.Responses = 95;
            q2.Answers.Add(new Answer("answer 2-1", 50));
            q2.Answers.Add(new Answer("answer 2-2", 25));
            q2.Answers.Add(new Answer("answer 2-3", 20));
            Question q3 = new Question();
            q3.Text = "Question Three";
            q3.Responses = 86;
            q3.Answers.Add(new Answer("answer 3-1", 20));
            q3.Answers.Add(new Answer("answer 3-2", 26));
            q3.Answers.Add(new Answer("answer 3-3", 40));

            QuestionCollection questions = new QuestionCollection();
            questions.Add(q1);
            questions.Add(q2);
            questions.Add(q3);
            this.game = new SimpleGame(questions);
        }
        public QuestionCreator()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.questions = new QuestionCollection();
        }
Beispiel #3
0
 public void Setup()
 {
     this.questions = new QuestionCollection();
     this.simpleQuestion = new Question();
     this.simpleQuestion.Text = "Sample Question";
     this.simpleQuestion.Responses = 100;
     this.simpleQuestion.Answers.Add(new Answer("answer 1", 25));
     this.simpleQuestion.Answers.Add(new Answer("answer 2", 50));
     this.simpleQuestion.Answers.Add(new Answer("answer 3", 25));
     this.filename = @"c:\questions.game";
     this.DeleteFile(this.filename);
 }
Beispiel #4
0
 public void SaveAndLoad()
 {
     Assert.IsTrue(questions.Count == 0);
     questions.Add(this.simpleQuestion);
     Assert.IsTrue(questions.Count == 1);
     questions.Save(filename);
     questions = null;
     questions = new QuestionCollection();
     Assert.IsTrue(questions.Count == 0);
     questions.Load(filename, false);
     Assert.IsTrue(questions.Count > 0);
 }
 public override int AddRange(QuestionCollection x)
 {
     throw new NotSupportedException("This is a Read Only Collection and can not be modified");
 }
Beispiel #6
0
 public GameBase(QuestionCollection questions)
 {
     this.questions = questions;
     this.index = 0;
 }
Beispiel #7
0
 public GameBase(string filename)
 {
     this.questions = new QuestionCollection();
     this.questions.Load(filename, false);
     index = 0;
 }
Beispiel #8
0
 public SimpleGame(QuestionCollection questions)
     : base(questions)
 {
     this.Initialize();
 }
 internal SyncQuestionCollection(QuestionCollection list)
     : base(Tag.Default)
 {
     rwLock = new System.Threading.ReaderWriterLock();
     collection = list;
 }
            public override int AddRange(QuestionCollection x)
            {
                int result = 0;
                rwLock.AcquireWriterLock(timeout);

                try {
                    result = collection.AddRange(x);
                }
                finally {
                    rwLock.ReleaseWriterLock();
                }

                return result;
            }
 internal ReadOnlyQuestionCollection(QuestionCollection list)
     : base(Tag.Default)
 {
     m_collection = list;
 }
 /// <summary>
 ///		Creates a read-only wrapper for a 
 ///     <c>QuestionCollection</c> instance.
 /// </summary>
 /// <returns>
 ///     An <c>QuestionCollection</c> wrapper that is read-only.
 /// </returns>
 public static QuestionCollection ReadOnly(QuestionCollection list)
 {
     if(list==null)
         throw new ArgumentNullException("list");
     return new ReadOnlyQuestionCollection(list);
 }
 /// <summary>
 ///		Initializes a new instance of the <c>Enumerator</c> class.
 /// </summary>
 /// <param name="tc"></param>
 internal Enumerator(QuestionCollection tc)
 {
     m_collection = tc;
     m_index = -1;
     m_version = tc.m_version;
 }
 /// <summary>
 ///		Initializes a new instance of the <c>QuestionCollection</c> class
 ///		that contains elements copied from the specified <c>QuestionCollection</c>.
 /// </summary>
 /// <param name="c">The <c>QuestionCollection</c> whose elements are copied to the new collection.</param>
 public QuestionCollection(QuestionCollection c)
 {
     m_array = new Question[c.Count];
     AddRange(c);
 }
        /// <summary>
        ///		Creates a shallow copy of the <see cref="QuestionCollection"/>.
        /// </summary>
        public virtual object Clone()
        {
            QuestionCollection newColl = new QuestionCollection(m_count);
            Array.Copy(m_array, 0, newColl.m_array, 0, m_count);
            newColl.m_count = m_count;
            newColl.m_version = m_version;

            return newColl;
        }
        /// <summary>
        ///		Adds the elements of another <c>QuestionCollection</c> to the current <c>QuestionCollection</c>.
        /// </summary>
        /// <param name="x">The <c>QuestionCollection</c> whose elements should be added to the end of the current <c>QuestionCollection</c>.</param>
        /// <returns>The new <see cref="QuestionCollection.Count"/> of the <c>QuestionCollection</c>.</returns>
        public virtual int AddRange(QuestionCollection x)
        {
            if (m_count + x.Count >= m_array.Length)
                EnsureCapacity(m_count + x.Count);

            Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
            m_count += x.Count;
            m_version++;

            return m_count;
        }
 /// <summary>
 ///		Creates a synchronized (thread-safe) wrapper for a 
 ///     <c>QuestionCollection</c> instance.
 /// </summary>
 /// <returns>
 ///     An <c>QuestionCollection</c> wrapper that is synchronized (thread-safe).
 /// </returns>
 public static QuestionCollection Synchronized(QuestionCollection list)
 {
     if(list==null)
         throw new ArgumentNullException("list");
     return new SyncQuestionCollection(list);
 }