roman-code

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

License

License

GroupId

GroupId

io.github.yogonza524
ArtifactId

ArtifactId

roman-code
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

roman-code
Convert roman to arabic numbers. You can define your own alphabet too
Project URL

Project URL

https://github.com/yogonza524/roman-code
Source Code Management

Source Code Management

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

Download roman-code

How to add to project

<!-- 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"]

Dependencies

compile (2)

Group / Artifact Type Version
org.apache.commons : commons-math3 jar 3.6.1
org.apache.commons : commons-lang3 jar 3.0

runtime (1)

Group / Artifact Type Version
com.google.guava : guava jar 29.0-jre

test (1)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.6.2

Project Modules

There are no modules declared in this project.

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

Versions

Version
0.0.1