Пример #1
0
        /// <summary>
        /// Creates the next section on the pyramid. Returns an exception if the value array is of the wrong size.
        /// </summary>
        /// <param name="array">value array of the next section on the pyramid</param>
        /// <returns>the next section of the pyramid</returns>
        public IPyramidSection CreateNext(int[] array)
        {
            if (array.Length != Step + 1)
            {
                throw new ArgumentException($"Expected array size: {Step + 1}, received array size: {array.Length}");
            }
            var newSection = new PyramidSection(array, this);

            return(newSection);
        }
Пример #2
0
 /// <summary>
 /// private constructor for linking cotinuous sections of the pyramid
 /// </summary>
 /// <param name="array">value array</param>
 /// <param name="prevSection">previous section that created this section</param>
 private PyramidSection(int[] array, PyramidSection prevSection)
 {
     Values    = array;
     Step      = array.Length;
     _previous = prevSection;
 }