| | 1 | | // -------------------------------------------------------------------------------- |
| | 2 | | // Copyright (C) 2025 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 | |
|
| 13 | 14 | | internal class RomanNumeral(RomanSymbol symbol, int value) |
| | 15 | | { |
| | 16 | | private static List<RomanNumeral>? _romanNumerals; |
| | 17 | |
|
| 96 | 18 | | public RomanSymbol Symbol { get; } = symbol; |
| 25 | 19 | | public int Value { get; } = value; |
| | 20 | |
|
| 1 | 21 | | public static RomanNumeral I => new(RomanSymbol.I, 1); |
| 1 | 22 | | public static RomanNumeral V => new(RomanSymbol.V, 5); |
| 1 | 23 | | public static RomanNumeral X => new(RomanSymbol.X, 10); |
| 1 | 24 | | public static RomanNumeral L => new(RomanSymbol.L, 50); |
| 1 | 25 | | public static RomanNumeral C => new(RomanSymbol.C, 100); |
| 1 | 26 | | public static RomanNumeral D => new(RomanSymbol.D, 500); |
| 1 | 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() |
| 1 | 37 | | { |
| 1 | 38 | | return new List<RomanNumeral> |
| 1 | 39 | | { |
| 1 | 40 | | I, |
| 1 | 41 | | V, |
| 1 | 42 | | X, |
| 1 | 43 | | L, |
| 1 | 44 | | C, |
| 1 | 45 | | D, |
| 1 | 46 | | M |
| 1 | 47 | | }; |
| 1 | 48 | | } |
| | 49 | | } |