roman-code

Convert roman to arabic numbers. You can define your own alphabet too

Лицензия

Лицензия

Группа

Группа

io.github.yogonza524
Идентификатор

Идентификатор

roman-code
Последняя версия

Последняя версия

0.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

roman-code
Convert roman to arabic numbers. You can define your own alphabet too
Ссылка на сайт

Ссылка на сайт

https://github.com/yogonza524/roman-code
Система контроля версий

Система контроля версий

https://github.com/yogonza524/roman-code/tree/master/

Скачать roman-code

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.yogonza524/roman-code/ -->
<dependency>
    <groupId>io.github.yogonza524</groupId>
    <artifactId>roman-code</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.yogonza524/roman-code/
implementation 'io.github.yogonza524:roman-code:0.0.1'
// https://jarcasting.com/artifacts/io.github.yogonza524/roman-code/
implementation ("io.github.yogonza524:roman-code:0.0.1")
'io.github.yogonza524:roman-code:jar:0.0.1'
<dependency org="io.github.yogonza524" name="roman-code" rev="0.0.1">
  <artifact name="roman-code" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.yogonza524', module='roman-code', version='0.0.1')
)
libraryDependencies += "io.github.yogonza524" % "roman-code" % "0.0.1"
[io.github.yogonza524/roman-code "0.0.1"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.apache.commons : commons-math3 jar 3.6.1
org.apache.commons : commons-lang3 jar 3.0

runtime (1)

Идентификатор библиотеки Тип Версия
com.google.guava : guava jar 29.0-jre

test (1)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-api jar 5.6.2

Модули Проекта

Данный проект не имеет модулей.

Maven Artifact Test all Test all Coverage Code size

Roman code

Translate any roman number to arabic or create your own alphabet to translate that symbols to arabic

Add to your project

To add as dependency using Maven, you should have at pom.xml:

<dependency>
  <groupId>io.github.yogonza524</groupId>
  <artifactId>roman-code</artifactId>
  <version>0.0.1</version>
</dependency>

To add as dependency using Gradle, you should have at build.gradle:

repositories {
    mavenCentral()
}

dependencies {
    implementation "io.github.yogonza524:roman-code:0.0.1"
}

Features

  • Translator roman-2-arabic
  • Translator alphabet-2-arabic
  • Translator arabic-2-roman (New) ✔️
  • Translator arabic-2-alphabet (New) ✔️

Stack

  • Openjdk 11.0.8 2020-07-14
  • Gradle 6.5

Samples

  • Validation test for roman translation
assertTrue(
    assertThrows(ConversionException.class, () -> ConvertToArabic.fromRoman("VX"), "")
        .getMessage()
        .contains("Sintaxis violation"));
  • Convert from roman to arabic
assertEquals(1914, ConvertToArabic.fromRoman("MCMXIV"));
  • Convert from arabic to roman
assertEquals("MCMXIV", ConvertToRoman.fromArabic(1914));
  • Create your own alphabet and convert to arabic
Alphabet alphabet =
    Alphabet.builder()
        .One("F")
        .Five("A")
        .Ten("C")
        .Fifty("U")
        .OneHundred("N")
        .FiveHundred("D")
        .Thousand("O")
        .build();

assertEquals(1914, ConvertToArabic.fromAlphabet("ONOCFA", alphabet));
  • If your alphabet is incomplete then you will receive an IncompleteAlphabetException
Alphabet.Builder alphabet =
    Alphabet.builder().One("G").Five("O").Ten("N").Fifty("Z").OneHundred("A");

assertTrue(
    assertThrows(
        IncompleteAlphabetException.class, () -> alphabet.build(), "")
            .getMessage()
            .contains("Alphabet must have 7 defined pair key-values")
    );
  • Remember: the alphabet created is immutable
assertNotNull(
    assertThrows(
        UnsupportedOperationException.class, () -> alphabet.getAlphabet().put("G", 19), ""));

Test all

./gradlew test

Try yourself

Check Test classes for more examples

Issues

Please contact to me to my email

Версии библиотеки

Версия
0.0.1