< Summary

Information
Class: LeetCode.Algorithms.RomanToInteger.Iterative.SubtractiveRomanNumeral
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\RomanToInteger\Iterative\SubtractiveRomanNumeral.cs
Line coverage
87%
Covered lines: 21
Uncovered lines: 3
Coverable lines: 24
Total lines: 49
Line coverage: 87.5%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_SecondSymbol()100%11100%
get_IV()100%11100%
get_IX()100%11100%
get_XL()100%11100%
get_XC()100%11100%
get_CD()100%11100%
get_CM()100%11100%
get_SubtractiveRomanNumerals()100%22100%
ToString()0%620%
GetSubtractiveRomanNumerals()100%11100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\RomanToInteger\Iterative\SubtractiveRomanNumeral.cs

#LineLine coverage
 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
 12namespace LeetCode.Algorithms.RomanToInteger.Iterative;
 13
 14internal class SubtractiveRomanNumeral(RomanSymbol firstSymbol, RomanSymbol secondSymbol, int value)
 615    : RomanNumeral(firstSymbol,
 616        value)
 17{
 18    private static List<SubtractiveRomanNumeral>? _subtractiveRomanNumerals;
 19
 2220    public RomanSymbol SecondSymbol { get; } = secondSymbol;
 21
 122    public static SubtractiveRomanNumeral IV => new(RomanSymbol.I, RomanSymbol.V, 4);
 123    public static SubtractiveRomanNumeral IX => new(RomanSymbol.I, RomanSymbol.X, 9);
 124    public static SubtractiveRomanNumeral XL => new(RomanSymbol.X, RomanSymbol.L, 40);
 125    public static SubtractiveRomanNumeral XC => new(RomanSymbol.X, RomanSymbol.C, 90);
 126    public static SubtractiveRomanNumeral CD => new(RomanSymbol.C, RomanSymbol.D, 400);
 127    public static SubtractiveRomanNumeral CM => new(RomanSymbol.C, RomanSymbol.M, 900);
 28
 29    public static List<SubtractiveRomanNumeral> SubtractiveRomanNumerals =>
 1230        _subtractiveRomanNumerals ??= GetSubtractiveRomanNumerals();
 31
 32    public override string ToString()
 033    {
 034        return Symbol.ToString() + SecondSymbol;
 035    }
 36
 37    private static List<SubtractiveRomanNumeral> GetSubtractiveRomanNumerals()
 138    {
 139        return
 140        [
 141            IV,
 142            IX,
 143            XC,
 144            XL,
 145            CD,
 146            CM
 147        ];
 148    }
 49}