Skip to content

Conversions implemented in Java - #433

Closed
RishiPrakash wants to merge 1 commit into
TheAlgorithms:masterfrom
RishiPrakash:master
Closed

RishiPrakash wants to merge 1 commit into
TheAlgorithms:masterfrom
RishiPrakash:master

Conversation

@RishiPrakash

Copy link
Copy Markdown

I have added 2 files for Roman to Int and Int to Roman conversion.

@RishiPrakash RishiPrakash mentioned this pull request May 2, 2018

@christianbender christianbender left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Work! I have some requests.

@@ -0,0 +1,101 @@
public class IntToRoman {

int value(int toPret){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look on the code style conventions Between methods and { a space.

intToRoman(a%toRepeat);
return str.toString();

}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct indentation.

for(int i =0;i<(a/toRepeat);i++){
str.append(corString);
}
if((a%toRepeat)>0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Between if and (...) one space. See

int intVal = 11128;
System.out.println(new IntToRoman().intToRoman(intVal));

}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct the indentation.

return 0;
}
}
public int romanToInt(String a1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct indentation.

return total;
}

public static void main(String[] s){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as above.

@@ -0,0 +1,101 @@
public class IntToRoman {

int value(int toPret){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This methods you can write as static. Then you don't need the instanciate a object of type IntToRoman and you can use this method right away in you main method.

return "";
}

StringBuffer str = new StringBuffer();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need StringBuffer you can simply use String.

@RishiPrakash

Copy link
Copy Markdown
Author

@christianbender Okay Christian I will update my files and will let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants