Exemplo n.º 1
0
        protected Rode(int?beadThreshold, Rode upperRode)
            : this()
        {
            if (beadThreshold.HasValue && beadThreshold <= 0)
            {
                throw new ArgumentOutOfRangeException("beadThreshold", beadThreshold, "Bead threshold must be null or a positive integer");
            }

            BeadThreshold = beadThreshold;
            UpperRode     = upperRode;
        }
Exemplo n.º 2
0
        protected Rode(int? beadThreshold, Rode upperRode)
            : this()
        {
            if (beadThreshold.HasValue && beadThreshold <= 0)
            {
                throw new ArgumentOutOfRangeException("beadThreshold", beadThreshold, "Bead threshold must be null or a positive integer");
            }

            BeadThreshold = beadThreshold;
            UpperRode = upperRode;
        }
        protected override string GetResult()
        {
            StringBuilder sb = new StringBuilder();

            for (int rodeIndex = rodes.Count - 1; rodeIndex >= 0; rodeIndex--)
            {
                Rode rode = rodes[rodeIndex];
                sb.Append(rode.BeadsCount);
            }

            string result = sb.ToString();

            return(result);
        }
Exemplo n.º 4
0
        public RomanRode(string symbol, int? beadThreshold, Rode upperRode)
            : base(beadThreshold, upperRode)
        {
            if (string.IsNullOrWhiteSpace(symbol))
            {
                throw new ArgumentException("Roman symbol was not set", "symbol");
            }

            bool isRomanSymbol = romanSymbols.Any(romanSymbol => romanSymbol.ToString(CultureInfo.InvariantCulture).Equals(symbol));

            if (!isRomanSymbol)
            {
                throw new ArgumentException(string.Format("{0} is not a valid Roman symbol", symbol), "symbol");
            }

            Symbol = symbol;
        }
Exemplo n.º 5
0
        public RomanRode(string symbol, int?beadThreshold, Rode upperRode)
            : base(beadThreshold, upperRode)
        {
            if (string.IsNullOrWhiteSpace(symbol))
            {
                throw new ArgumentException("Roman symbol was not set", "symbol");
            }

            bool isRomanSymbol = romanSymbols.Any(romanSymbol => romanSymbol.ToString(CultureInfo.InvariantCulture).Equals(symbol));

            if (!isRomanSymbol)
            {
                throw new ArgumentException(string.Format("{0} is not a valid Roman symbol", symbol), "symbol");
            }

            Symbol = symbol;
        }
Exemplo n.º 6
0
        public string PerformSumming(string leftOperand, string rightOperand)
        {
            Rode initialRode = GetInitialRode();

            if (initialRode == null)
            {
                throw new InvalidOperationException("This abacus has no rodes, thus is unable to perform any calculus");
            }

            List <Bead> leftOperandBeads;
            List <Bead> rightOperandBeads;

            if (!TryDecompose(leftOperand, out leftOperandBeads))
            {
                throw new ArgumentException(string.Format("{0} is not a valid numeral", leftOperand), "leftOperand");
            }

            if (!TryDecompose(rightOperand, out rightOperandBeads))
            {
                throw new ArgumentException(string.Format("{0} is not a valid numeral", rightOperand), "rightOperand");
            }

            List <Bead> beads = new List <Bead>();

            beads.AddRange(leftOperandBeads);
            beads.AddRange(rightOperandBeads);

            foreach (Bead bead in beads)
            {
                initialRode.Add(bead);
            }

            string result = GetResult();

            return(result);
        }
Exemplo n.º 7
0
 public ArabicRode(Rode upperRode)
     : base(9, upperRode)
 {
 }
Exemplo n.º 8
0
 public ArabicRode(Rode upperRode)
     : base(9, upperRode)
 {
 }