public List <int> GetEnds()
        {
            // Поиск концевых элементов дерева. Номер элемента не встрачается в массиве Bases.
            bool isEnd;

            Ends.Add(0);
            for (int i = 1; i < Bases[0] + 1; ++i)
            {
                isEnd = true;
                for (int j = i + 1; j < Bases[0] + 1; ++j)
                {
                    if (Bases[j] == i || Ends.Contains(i))
                    {
                        isEnd = false;
                        break;
                    }
                }
                if (isEnd)
                {
                    Ends.Add(i);
                }
            }
            Ends[0] = Ends.Count - 1;
            return(Ends);
        }
Beispiel #2
0
        public void Start()
        {
            // Initiation random doors
            for (int i = 0; i < 4; i++)
            {
                while (true)
                {
                    ulong r = (ulong)rnd.Next(2, 9);
                    if (!doors.Contains(r))
                    {
                        doors.Add(r);
                        break;
                    }
                }
            }
            doors.Add(0);

            // Start
            Console.WriteLine("The game of doors\n");
            Console.WriteLine("Welcome in my castle, you must choose the right door.");
            PrintArr(doors);

            // Main loop
            byte  n = 0;
            ulong door;

            while (true)
            {
                door = GetDoor();
                Console.WriteLine();

                if (door == 0)
                {
                    if (n != 0)
                    {
                        n--;
                    }
                    Console.WriteLine("You return to the previouse doors");

                    PreviousLvl();
                }
                else
                {
                    n++;
                    Ends end = (n == 1 || n == 2 || n == 3) ? (Ends)n : Ends.th;
                    Console.WriteLine($"You move forward throught {n}{end} door");

                    NextLvl(door);
                }

                if (IsWin())
                {
                    Console.WriteLine($"\nYou win! your score is: {door} after {n} doors");
                    return;
                }

                PrintArr(doors);
            }
        }
Beispiel #3
0
        public void No_match_if_string_does_not_end_with_substring()
        {
            var matcher = Ends.With("bob");

            var matches = matcher.Matches("the cat sat on the mat");

            Assert.That(matches, Is.False());
        }
Beispiel #4
0
 public CharRange(byte[,] range)
     : this()
 {
     for (int i = 0; i < range.GetLength(0); i++)
     {
         Starts.Add((char)range[i, 0]);
         Ends.Add((char)range[i, 1]);
     }
 }
Beispiel #5
0
        public void Describe_to()
        {
            var matcher     = Ends.With("bob");
            var description = new StringDescription();

            matcher.DescribeTo(description);

            Assert.That(description.ToString(), Is.EqualTo("a string ending with \"bob\""));
        }
Beispiel #6
0
        public void Describe_mismatch()
        {
            var matcher     = Ends.With("bob");
            var description = new StringDescription();

            matcher.DescribeMismatch("the cat sat on the mat", description);

            Assert.That(description.ToString(), Is.EqualTo("was \"the cat sat on the mat\""));
        }
        public override string ToString()
        {
            var endsAsArray = Ends.ToArray();

            if (endsAsArray.Length < 2)
            {
                return("IRQ: " + endsAsArray[0].ToShortString());
            }
            return("IRQs: " + endsAsArray.Select(x => x.ToShortString()).Aggregate((x, y) => x + ',' + y));
        }
        /// <summary>
        ///     handle the End child element
        /// </summary>
        /// <param name="reader"> XmlReader positioned at the end element </param>
        private void HandleEndElement(XmlReader reader)
        {
            DebugCheck.NotNull(reader);
            var end = new RelationshipEnd(this);

            end.Parse(reader);

            if (Ends.Count == 2)
            {
                AddError(ErrorCode.InvalidAssociation, EdmSchemaErrorSeverity.Error, Strings.TooManyAssociationEnds(FQName));
                return;
            }

            Ends.Add(end);
        }
Beispiel #9
0
        /// <summary>
        /// handle the End child element
        /// </summary>
        /// <param name="reader">XmlReader positioned at the end element</param>
        private void HandleEndElement(XmlReader reader)
        {
            Debug.Assert(reader != null);
            RelationshipEnd end = new RelationshipEnd(this);

            end.Parse(reader);

            if (Ends.Count == 2)
            {
                AddError(ErrorCode.InvalidAssociation, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.TooManyAssociationEnds(FQName));
                return;
            }

            Ends.Add(end);
        }
Beispiel #10
0
        public void AddEnd(End end)
        {
            if (Ends.Count == this.GetNumberOfEnds())
            {
                throw new Exception("Cannot add another end.  Already reached the maximum number of ends");
            }

            if (!Ends.ContainsKey(end.EndNumber))
            {
                Ends.Add(end.EndNumber, end);
            }
            else
            {
                throw new Exception("Linescore already contains this end number");
            }
        }
Beispiel #11
0
 /// <summary>
 /// Gets or sets the start and end of the range at the specified index.
 /// </summary>
 /// <param name="i"></param>
 /// <returns></returns>
 public KeyValuePair <char, char> this[int i]
 {
     get
     {
         var kvp = new KeyValuePair <char, char>(Starts[i], Ends[i]);
         return(kvp);
     }
     set
     {
         if (Starts.Count <= i)
         {
             Starts[i] = value.Key;
             Ends[i]   = value.Value;
         }
         else
         {
             Starts.Add(value.Key);
             Ends.Add(value.Value);
         }
     }
 }
Beispiel #12
0
 public CharRange(CharRange range)
     : this()
 {
     Starts.AddRange(range.Starts);
     Ends.AddRange(range.Ends);
 }
Beispiel #13
0
 public void Match_if_string_ends_with_substring()
 {
     Assert.That("the cat sat on the mat", Ends.With("mat"));
 }
Beispiel #14
0
 public void Case_insensitive_match_if_string_ends_with_substring()
 {
     Assert.That("the cat sat on the mat", Ends.With("Mat").CaseInsensitive());
 }
Beispiel #15
0
 public override bool CanBePutToDiagram(Diagram targetDiagram, IEnumerable <Element> ignoredElements)
 {
     return(Ends.All(end => targetDiagram.IsElementPresent(end.Class) || ignoredElements.Contains(end.Class)));
 }