Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
roman-numerals-converter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Illia Baida
roman-numerals-converter
Commits
866e77f9
Commit
866e77f9
authored
Mar 30, 2020
by
Illia Baida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decimal to Roman (ready to test)
parent
c758a898
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
App.js
src/App.js
+3
-3
converter.js
src/helper/converter.js
+9
-10
No files found.
src/App.js
View file @
866e77f9
...
...
@@ -40,12 +40,12 @@ function App() {
<
div
className
=
"App"
>
<
header
className
=
"App-header"
>
<
img
src
=
{
logo
}
className
=
"App-logo"
alt
=
"logo"
/>
<
h
2
>
Converter
:
Roman
to
Decimal
<
/h2
>
<
p
>
Available
range
:
from
1
to
3999
<
/p
>
<
h
3
>
Converter
:
Roman
to
Decimal
<
/h3
>
<
input
name
=
{
Inputs
.
toDecimal
}
onChange
=
{
handleChange
}
/
>
<
span
>
Value
is
:
{
converted
.
toDecimal
}
<
/span
>
<
h
2
>
Converter
:
Decimal
to
Roman
<
/h2
>
<
h
3
>
Converter
:
Decimal
to
Roman
<
/h3
>
<
input
name
=
{
Inputs
.
toRoman
}
onChange
=
{
handleChange
}
/
>
<
span
>
Value
is
:
{
converted
.
toRoman
}
<
/span
>
<
/header
>
...
...
src/helper/converter.js
View file @
866e77f9
...
...
@@ -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
E
rror
(
"Cannot be greater than 1"
);
console
.
e
rror
(
"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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment