コード例 #1
0
 /// <summary>
 /// Determines whether this object is equal to another object. They are
 /// considered equal, if the other object is enumerable and contains
 /// the same moves in the same order.
 /// </summary>
 /// <param name="obj">The object to compare to.</param>
 /// <returns>
 /// Whether this object is equal to the other object.
 /// </returns>
 public override bool Equals(object obj)
 {
     if (obj is IEnumerable <Move> )
     {
         return(Alg.AreEqual(this, obj as IEnumerable <Move>));
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        /// <summary>
        /// Repeat an alg.
        /// </summary>
        /// <param name="alg">The alg to repeat.</param>
        /// <param name="numTimes">The number of repetitions.</param>
        /// <returns>
        /// <paramref name="alg"/> repeated for the specified number of times.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="alg"/> is null.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown if <paramref name="numTimes"/> is negative.
        /// </exception>
        public static Alg operator*(Alg alg, int numTimes)
        {
            if (alg is null)
            {
                throw new ArgumentNullException(nameof(alg) + " is null.");
            }
            if (numTimes < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(numTimes) + " is smaller than 0: " + numTimes);
            }

            Alg repeatedAlg = Alg.Empty;

            for (int repetition = 0; repetition < numTimes; repetition++)
            {
                repeatedAlg += alg;
            }
            return(repeatedAlg);
        }
コード例 #3
0
 /// <summary>
 /// <inheritdoc/>
 /// Same as <see cref="ToString(IEnumerable{Move})"/>.
 /// </summary>
 /// <returns><inheritdoc/></returns>
 public override string ToString()
 => Alg.ToString(_moves);
コード例 #4
0
 /// <summary>
 /// Rotate this alg.
 /// </summary>
 /// <param name="rotation">The rotation to apply.</param>
 /// <returns>
 /// This object rotated by <paramref name="rotation"/>.
 /// </returns>
 public Alg Rotate(Rotation rotation)
 => Alg.Rotate(this, rotation);
コード例 #5
0
 /// <summary>
 /// Get the inverse of this alg (reverse the sequence and change and
 /// change the direction of all moves).
 /// </summary>
 /// <returns>The inverse of this object.</returns>
 public Alg Inverse()
 => Alg.Inverse(this);
コード例 #6
0
 /// <summary>
 /// Determines whether this alg is equal to another alg. They are
 /// considered equal, if both contain the same moves in the same
 /// order.
 /// </summary>
 /// <param name="other">The alg to compare to.</param>
 /// <returns>
 /// Whether this alg is equal to the other alg.
 /// </returns>
 public bool Equals(IEnumerable <Move> other)
 => Alg.AreEqual(this, other);