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 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); }
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; }
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; }
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); }
public ArabicRode(Rode upperRode) : base(9, upperRode) { }
public ArabicRode(Rode upperRode) : base(9, upperRode) { }