| | | 1 | | // -------------------------------------------------------------------------------- |
| | | 2 | | // Copyright (C) 2026 Eugene Eremeev (also known as Yevhenii Yeriemeieiv). |
| | | 3 | | // All Rights Reserved. |
| | | 4 | | // -------------------------------------------------------------------------------- |
| | | 5 | | // This software is the confidential and proprietary information of Eugene Eremeev |
| | | 6 | | // (also known as Yevhenii Yeriemeieiv) ("Confidential Information"). You shall not |
| | | 7 | | // disclose such Confidential Information and shall use it only in accordance with |
| | | 8 | | // the terms of the license agreement you entered into with Eugene Eremeev (also |
| | | 9 | | // known as Yevhenii Yeriemeieiv). |
| | | 10 | | // -------------------------------------------------------------------------------- |
| | | 11 | | |
| | | 12 | | namespace LeetCode.Algorithms.RomanToInteger.Iterative; |
| | | 13 | | |
| | 39 | 14 | | internal class RomanNumeral(RomanSymbol symbol, int value) |
| | | 15 | | { |
| | | 16 | | private static List<RomanNumeral>? _romanNumerals; |
| | | 17 | | |
| | 122 | 18 | | public RomanSymbol Symbol { get; } = symbol; |
| | 51 | 19 | | public int Value { get; } = value; |
| | | 20 | | |
| | 3 | 21 | | public static RomanNumeral I => new(RomanSymbol.I, 1); |
| | 3 | 22 | | public static RomanNumeral V => new(RomanSymbol.V, 5); |
| | 3 | 23 | | public static RomanNumeral X => new(RomanSymbol.X, 10); |
| | 3 | 24 | | public static RomanNumeral L => new(RomanSymbol.L, 50); |
| | 3 | 25 | | public static RomanNumeral C => new(RomanSymbol.C, 100); |
| | 3 | 26 | | public static RomanNumeral D => new(RomanSymbol.D, 500); |
| | 3 | 27 | | public static RomanNumeral M => new(RomanSymbol.M, 1000); |
| | | 28 | | |
| | 9 | 29 | | public static List<RomanNumeral> RomanNumerals => _romanNumerals ??= GetRomanNumerals(); |
| | | 30 | | |
| | | 31 | | public override string ToString() |
| | 0 | 32 | | { |
| | 0 | 33 | | return Symbol.ToString(); |
| | 0 | 34 | | } |
| | | 35 | | |
| | | 36 | | private static List<RomanNumeral> GetRomanNumerals() |
| | 3 | 37 | | { |
| | 3 | 38 | | return new List<RomanNumeral> |
| | 3 | 39 | | { |
| | 3 | 40 | | I, |
| | 3 | 41 | | V, |
| | 3 | 42 | | X, |
| | 3 | 43 | | L, |
| | 3 | 44 | | C, |
| | 3 | 45 | | D, |
| | 3 | 46 | | M |
| | 3 | 47 | | }; |
| | 3 | 48 | | } |
| | | 49 | | } |