public void CreateRepetition() { var arabicFive = new ArabicNumber(5); var result = RomanSymbolRepetition.CanCreateRepetition(RomanSymbols.V, arabicFive); Assert.True(result); }
public void NotCreateEmptyRepetition() { var arabicThree = new ArabicNumber(3); var result = RomanSymbolRepetition.CanCreateRepetition(RomanSymbols.V, arabicThree); Assert.False(result); }
public void TenUnitBeforNextSymbolp(int input, string exptected) { var arabic = new ArabicNumber(input); var sut = new RomanConvertibleCollection(arabic); var actual = sut.ToString(); Assert.Equal(exptected, actual); }
public void RepetitionCharacters(int input, string exptected) { var arabic = new ArabicNumber(input); var sut = new RomanConvertibleCollection(arabic); var actual = sut.ToString(); Assert.Equal(exptected, actual); }
public static int CalculateNumberOfOcurrances(RomanSymbol romanSymbol, ArabicNumber arabic) { if (arabic.Equals(ArabicNumber.Zero)) { return(0); } var result = arabic.DevidedBy(romanSymbol); return(result); }
private static SymbolResult ProcessSymbol(ref ArabicNumber arabic, Symbol symbol) { SymbolResult result = new SymbolResult(); while (arabic.GreaterThanOrEqualTo(symbol)) { result.AppendToResult(symbol); arabic.SubtractFrom(symbol); } return(result); }
public static string Convert(int value) { ArabicNumber arabic = new ArabicNumber(value); SymbolStringBuilder result = new SymbolStringBuilder(); foreach (Symbol symbol in SymbolDictionaries.GetRomanSymbols()) { SymbolResult symbolResult = ProcessSymbol(ref arabic, symbol); result.Append(symbolResult); } return(result.GetValue()); }
public static RomanSymbol[] GetItemsFromEquivalent(ArabicNumber arabic) => GetItemsFromEquivalent(arabic.Value);
public static bool ContainsEquivalent(ArabicNumber arabic) => ContainsEquivalent(arabic.Value);
public Symbol(ArabicNumber number, string value) { _number = number; _value = value; }
public static bool CanCreateRepetition(RomanSymbol romanSymbol, ArabicNumber arabic) => CanCreateRepetition(romanSymbol, arabic.Value);
public static RomanSymbolRepetition FromOcurrancesOfSymbol(RomanSymbol romanSymbol, ArabicNumber arabic) { if (!CanCreateRepetition(romanSymbol, arabic)) { return(Empty); } var count = CalculateNumberOfOcurrances(romanSymbol, arabic); return(new RomanSymbolRepetition(romanSymbol, count)); }
public void SubtractFrom(Symbol symbol) { ArabicNumber number = symbol.GetArabicNumber(); _arabicNumber -= number.ToInt(); }
public bool GreaterThanOrEqualTo(Symbol symbol) { ArabicNumber number = symbol.GetArabicNumber(); return(_arabicNumber >= number.ToInt()); }