Commit 866e77f9 authored by Illia Baida's avatar Illia Baida

Decimal to Roman (ready to test)

parent c758a898
......@@ -40,12 +40,12 @@ function App() {
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Converter: Roman to Decimal</h2>
<p>Available range: from 1 to 3999</p>
<h3>Converter: Roman to Decimal</h3>
<input name={Inputs.toDecimal} onChange={handleChange} />
<span>Value is: {converted.toDecimal}</span>
<h2>Converter: Decimal to Roman</h2>
<h3>Converter: Decimal to Roman</h3>
<input name={Inputs.toRoman} onChange={handleChange} />
<span>Value is: {converted.toRoman}</span>
</header>
......
......@@ -8,6 +8,7 @@ export default class Converter {
D: 500,
M: 1000
};
static _dictionaryValues = Object.values(this.Dictionary).reverse();
static _dictionaryNames = Object.keys(this.Dictionary).reverse();
......@@ -82,14 +83,8 @@ export default class Converter {
console.log("calculatedDictionary", calculatedDictionary);
const skippedNames = [];
for (let index = 0; index < this._dictionaryNames.length; index++) {
const sign = this._dictionaryNames[index];
if(skippedNames.indexOf(sign) !== -1){
console.log('skipping', sign);
continue;
}
if (sign in calculatedDictionary) {
if (this._isSignDescribesDecimalGroup(sign)) {
......@@ -117,11 +112,10 @@ export default class Converter {
lowerName,
calculatedDictionary[lowerName]
)}`;
// skip
skippedNames.push(lowerName);
}
calculatedDictionary[lowerName] = 0;
} else {
throw new Error("Cannot be greater than 1");
console.error("Cannot be greater than 1");
}
}
}
......@@ -130,5 +124,10 @@ export default class Converter {
return romanExpression;
}
static fromRoman(roman) {}
static fromRoman(romanExpression) {
let result = 0;
const signs = romanExpression.split('');
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment