Convert to LowerCase ( code review lab)#194
Conversation
AllTestCasesToLowerCase.java file has all the test cases. ConvertToLowerCase.java, we give input and expect the output result.txt has all the tested test cases
|
|
||
| public class ToLowerCase { | ||
|
|
||
| String turkish_lang = "tr"; |
There was a problem hiding this comment.
I feel that naming conventions for attribute names in camelCase looks better rather than separating with "_"
Ex: turkish_lang to turkishLang
| String result = object.wordToLowerCase(words[i],lang[i],langWithNoLowerCase); | ||
| printWriter.println(words[i]+ " " + lang[i] +" "+result); | ||
| } | ||
|
|
There was a problem hiding this comment.
I can suggest that elimination of unused extra empty lines, It might make code looks messy. There are a lot in the code.
There was a problem hiding this comment.
Okay, we shall handle the indentation and the line spacing
| } | ||
| else if(language.startsWith(irish_lang)) | ||
| { | ||
| if((word.charAt(0) == lowerCase_n || word.charAt(0) == lowerCase_t) && |
There was a problem hiding this comment.
A better logic for this implementation is to use for loop , defining the possibilities in an array. As you can see that if else multiple conditions is not an good way of sorting.
There was a problem hiding this comment.
noted! we shall implement this better using a for loop
| return lower1; | ||
| } | ||
|
|
||
| boolean isLanguage_with_no_lowerCase(String []langWithNoLowerCase,String language) |
There was a problem hiding this comment.
I felt that in the above method , method name looks good than here as it uses camel casing. You can code better following single naming convection for all the methods in the class.
| import java.io.UnsupportedEncodingException; | ||
| import java.util.*; | ||
|
|
||
| public class ToLowerCase { |
There was a problem hiding this comment.
I think in java a class name should be the file name they should match. However we know that we can just have a single class in single .java file , Its a good way to name the class after file.
| "NATHAIR", "tOthair", "tETHAIR", "tITHAIR", "nÓg", "nÕg","对不起","ごめんなさい", "KASIM", "KASIM", "ΠΌΛΗΣ", "官话", "ภาษาไทย", "ΠΌΛΗΣ", "ΠΌΛΗΣΠΌΛΗΣ"}; | ||
|
|
||
| // words in their respective languages | ||
| String lang[] = {"en", "en-US", "en-IE", "en-Latn", "ga", "ga", "ga", "ga", "ga", |
There was a problem hiding this comment.
I think when one value in an array satisfies condition duplicates are not necessary in array -> "ga".
|
|
||
| PrintWriter printWriter = null; | ||
| try { | ||
| printWriter = new PrintWriter("D:\\SLU\\Spring 23\\PSD\\result.txt", "UTF-8"); |
There was a problem hiding this comment.
I think the path can be the same directory where class is present because Path fluctuates and creates mess on different systems if you run. printWriter - > path
|
Hello, I have modified the code as per the given suggestions and added the JUnit test cases, Could you please confirm |
|
Sign Off all verified. |
| String irishLang = "ga"; | ||
| String latinDotlessI = "\u0131"; | ||
|
|
||
| String upperCaseI = "I"; |
There was a problem hiding this comment.
These three maybe unnecessary? I'm happy with a literal 't' for example.
|
|
||
| import java.util.*; | ||
|
|
||
| public class ConvertToLowerCase { |
There was a problem hiding this comment.
I don't like the repeated code here and in AllTestCasesToLower....
| } } | ||
| } | ||
|
|
||
| return lower1; |
AllTestCasesToLowerCase.java file has all the test cases. ConvertToLowerCase.java, we give input and expect the output result.txt has all the tested test cases