コード例 #1
0
 public static Test10 initialize()
 {
     if (numberInstanced < 2)
     {
         numberInstanced++;
         instanceOne = new Test10();
         return(instanceOne);
     }
     else
     {
         return(null);
     }
 }
コード例 #2
0
ファイル: TestFactory.cs プロジェクト: andrewmohn/CIS297
        public TestVersion createTest(string test)
        {
            TestVersion temp = null;

            try
            {
                if (test == "Word90")
                {
                    temp = Test90.initialize();
                }
                else if (test == "Word00")
                {
                    temp = Test00.initialize();
                }
                else if (test == "Word10")
                {
                    temp = Test10.initialize();
                }
                else if (test == "Word17")
                {
                    temp = Test17.initialize();
                }
                else
                {
                    temp = null;
                    throw new ArgumentException("Invalid version value.");
                }

                if (temp == null)
                {
                    throw new AccessViolationException($"Two members of the {test} item have already been tested.");
                }
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }

            catch (AccessViolationException e)
            {
                Console.WriteLine(e.Message);
            }
            return(temp);
        }