dhartoto / intergalactic_converter

A simple OO ruby CLI app that converts intergalactic numbers to human numbers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

INTERGALACTIC NUMERALS CONVERTER

by: Dito Hartoto

Contents:

  • Versions

  • Summary

  • Design

  • Instructions

Versions:

  • ruby version 2.2.0

  • rspec 3.2.3

Summary:

This Ruby CLI application was built to practice my Object Oriented Design. The application is built for fictitious intergalactic metal merchants with two use cases:

1) Intergalactic metal merchants use the application to convert Intergalactic numerals to human numerals. For example ‘prok glob’ converts to 4.

2) They also use the application to calculate the total value of materials from intergalactic numerals. For example ‘prok glob platinum’ calculates the value of 4 units of platinum ($20 see below), which equals $80.

Metal Merchants record values of the Intergalactic numerals in a note.txt file, which is imported and used for conversion. The note.txt file is in the following format and saved in the ‘public’ folder:

glob is I
prok is V
pish is X
tegj is L

Intergalactic numerals are similar to roman numerals. The table below lists the value of each intergalactic numeral:

1   = I = glob
5   = V = prok
10  = X = pish
50  = L = tegj
100 = C = zyah

Intergalactic metal merchants trade in 4 types of metal with fixed market value:

silver   = $17
gold     = $14,450
iron     = $195.5
platinum = $20

Design:

  • The application has the following objects:

    • QueryEngine: responsibility is to direct user query through validation to conversion.

    • Query: responsibility is to holds the users query.

    • Note: responsible for importing note.txt file.

    • MaterialsValidator: responsible for validating if the material entered is valid.

    • GalacticNumeralsValidator: responsible for validating if the intergalactic numerals entered by the user is correct.

    • RomanNumerals: responsible for converting from intergalactic numerals to roman numerals.

    • RomanNumeralsValidator: responsible for checking if the user input passes the roman numerals rules as stated in the assignment (see Assumptions).

    • RomanNumeralsConverter: responsible for converting roman numerals to integers

  • The application has 1 module:

    • RomanReference: provides the method to convert from single roman symbols to integers. This is shared between RomanNumeralsConverter and RomanNumeralsValidator.

Instructions:

  • Note file is stored in the public folder.

  • To run the application enter ‘ruby converter.rb’ from the applications root directory.

  • The application will prompt you on what to do.

    • Choose 1 if you only want to convert intergalactic (IG) numerals

    • Choose 2 if you want to calculate the total credit of materials given in IG numerals.

    • Choose 3 to exit the application.

    • The application will continue until 3 is selected.

To run the tests enter ‘rspec’ from the application root

About

A simple OO ruby CLI app that converts intergalactic numbers to human numbers.


Languages

Language:Ruby 100.0%