예제 #1
0
 protected override void ValidateRepeat(RomanCalculator connector)
 {
     if (connector.Contains($"{this.ToString()}{this.ToString()}"))
     {
         throw new Exception($"{this.ToString()} can nerver be repeated.");
     }
 }
예제 #2
0
        protected virtual void ValidateRepeat(RomanCalculator connector)
        {
            if (connector.Contains($"{this.ToString()}{this.ToString()}{this.ToString()}{this.ToString()}"))
            {
                throw new Exception($"{this.Symbol} can not be repeated over than 3 times in successive.");
            }

            MatchCollection matches = null;

            if (connector.Contains(new Regex("^[" + this.ToString() + "]{3}([.]){1}" + this.ToString() + "$"), out matches))
            {
                var midNumber = RomanNumber.Create(matches[0].Value);
                if (midNumber.Value >= this.Value)
                {
                    throw new Exception($"{midNumber.Symbol} must be less than {this.ToString()}'s value : {this.ToString()}.");
                }
            }
        }