From 13cfc85b61fda65538992692ebc3d708189ff072 Mon Sep 17 00:00:00 2001 From: MVR9999 <57259592+MVR9999@users.noreply.github.com> Date: Thu, 16 Feb 2023 12:06:34 -0600 Subject: [PATCH 1/5] Convert to LowerCase ( code review lab) 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 --- S23/mvr9999/AllTestCasesToLowerCase.java | 100 +++++++++++++++++++++++ S23/mvr9999/ConvertToLowerCase.java | 84 +++++++++++++++++++ S23/mvr9999/result.txt | 24 ++++++ 3 files changed, 208 insertions(+) create mode 100644 S23/mvr9999/AllTestCasesToLowerCase.java create mode 100644 S23/mvr9999/ConvertToLowerCase.java create mode 100644 S23/mvr9999/result.txt diff --git a/S23/mvr9999/AllTestCasesToLowerCase.java b/S23/mvr9999/AllTestCasesToLowerCase.java new file mode 100644 index 00000000..f7c0a877 --- /dev/null +++ b/S23/mvr9999/AllTestCasesToLowerCase.java @@ -0,0 +1,100 @@ +package com.firstspringproject.Controllers; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.*; + +public class ToLowerCase { + + String turkish_lang = "tr"; + String azerbaijani_lang = "az"; + String irish_lang = "ga"; + String latin_Dotless_I = "\u0131"; + + String upper_Case_I = "I"; + char lowerCase_t = 't'; + char lowerCase_n = 'n'; + + // Ascii values of vowels + int upperCase_A = 65; + int upperCase_E = 69; + int upperCase_I = 73; + int upperCase_O = 79; + int upperCase_U = 85; + + int upperCase_Irish_A = 193; + int upperCase_Irish_E = 201; + int upperCase_Irish_I = 205; + int upperCase_Irish_O = 211; + int upperCase_Irish_U = 218; + public static void main(String args[]) throws UnsupportedEncodingException + { + // words to be converted to lowerCase + String words[] = {"HELLO", "WORLD", "cAmEl", "---OK", "tAcht", "tACHT", "TACHT", "nAthair", "nATHAIR", + "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", + "ga", "ga", "ga", "ga", "ga-IE", "ga-IE", "zh", "ja", "az", "en", "el", "zh-Hans", "th", "el-GR", "el-GR"}; + + String langWithNoLowerCase[] = {"zh", "ja", "th"}; + + PrintWriter printWriter = null; + try { + printWriter = new PrintWriter("D:\\SLU\\Spring 23\\PSD\\result.txt", "UTF-8"); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + ToLowerCase object = new ToLowerCase(); + for(int i=0;i Date: Tue, 21 Feb 2023 19:43:49 -0600 Subject: [PATCH 2/5] Update AllTestCasesToLowerCase.java --- S23/mvr9999/AllTestCasesToLowerCase.java | 73 ++++++++++++------------ 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/S23/mvr9999/AllTestCasesToLowerCase.java b/S23/mvr9999/AllTestCasesToLowerCase.java index f7c0a877..744f68f3 100644 --- a/S23/mvr9999/AllTestCasesToLowerCase.java +++ b/S23/mvr9999/AllTestCasesToLowerCase.java @@ -4,29 +4,31 @@ import java.io.UnsupportedEncodingException; import java.util.*; -public class ToLowerCase { +public class AllTestCasesToLowerCase { - String turkish_lang = "tr"; - String azerbaijani_lang = "az"; - String irish_lang = "ga"; - String latin_Dotless_I = "\u0131"; + String turkishLang = "tr"; + String azerbaijaniLang = "az"; + String irishLang = "ga"; + String latinDotlessI = "\u0131"; - String upper_Case_I = "I"; - char lowerCase_t = 't'; - char lowerCase_n = 'n'; + String upperCaseI = "I"; + char lowerCaseT = 't'; + char lowerCaseN = 'n'; // Ascii values of vowels - int upperCase_A = 65; - int upperCase_E = 69; - int upperCase_I = 73; - int upperCase_O = 79; - int upperCase_U = 85; + int upperCaseA = 65; + int upperCaseE = 69; + int upperCaseIInt = 73; + int upperCaseO = 79; + int upperCaseU = 85; - int upperCase_Irish_A = 193; - int upperCase_Irish_E = 201; - int upperCase_Irish_I = 205; - int upperCase_Irish_O = 211; - int upperCase_Irish_U = 218; + int upperCaseIrishA = 193; + int upperCaseIrishE = 201; + int upperCaseIrishI = 205; + int upperCaseIrishO = 211; + int upperCaseIrishU = 218; + + int vowels[]={upperCaseA,upperCaseE,upperCaseIInt,upperCaseO,upperCaseU,upperCaseIrishA,upperCaseIrishE,upperCaseIrishI,upperCaseIrishO,upperCaseIrishU}; public static void main(String args[]) throws UnsupportedEncodingException { // words to be converted to lowerCase @@ -38,7 +40,7 @@ public static void main(String args[]) throws UnsupportedEncodingException "ga", "ga", "ga", "ga", "ga-IE", "ga-IE", "zh", "ja", "az", "en", "el", "zh-Hans", "th", "el-GR", "el-GR"}; String langWithNoLowerCase[] = {"zh", "ja", "th"}; - + PrintWriter printWriter = null; try { printWriter = new PrintWriter("D:\\SLU\\Spring 23\\PSD\\result.txt", "UTF-8"); @@ -46,49 +48,50 @@ public static void main(String args[]) throws UnsupportedEncodingException // TODO Auto-generated catch block e.printStackTrace(); } - ToLowerCase object = new ToLowerCase(); + AllTestCasesToLowerCase object = new AllTestCasesToLowerCase(); for(int i=0;i Date: Tue, 21 Feb 2023 19:44:27 -0600 Subject: [PATCH 3/5] Update ConvertToLowerCase.java --- S23/mvr9999/ConvertToLowerCase.java | 64 +++++++++++++++-------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/S23/mvr9999/ConvertToLowerCase.java b/S23/mvr9999/ConvertToLowerCase.java index 93acafed..8ec8232a 100644 --- a/S23/mvr9999/ConvertToLowerCase.java +++ b/S23/mvr9999/ConvertToLowerCase.java @@ -4,28 +4,29 @@ public class ConvertToLowerCase { - String turkish_lang = "tr"; - String azerbaijani_lang = "az"; - String irish_lang = "ga"; - String latin_Dotless_I = "\u0131"; + String turkishLang = "tr"; + String azerbaijaniLang = "az"; + String irishLang = "ga"; + String latinDotlessI = "\u0131"; - String upper_Case_I = "I"; - char lowerCase_t = 't'; - char lowerCase_n = 'n'; + String upperCaseI = "I"; + char lowerCaseT = 't'; + char lowerCaseN = 'n'; // Ascii values of vowels - int upperCase_A = 65; - int upperCase_E = 69; - int upperCase_I = 73; - int upperCase_O = 79; - int upperCase_U = 85; + int upperCaseA = 65; + int upperCaseE = 69; + int upperCaseIInt = 73; + int upperCaseO = 79; + int upperCaseU = 85; - int upperCase_Irish_A = 193; - int upperCase_Irish_E = 201; - int upperCase_Irish_I = 205; - int upperCase_Irish_O = 211; - int upperCase_Irish_U = 218; + int upperCaseIrishA = 193; + int upperCaseIrishE = 201; + int upperCaseIrishI = 205; + int upperCaseIrishO = 211; + int upperCaseIrishU = 218; + int vowels[]={upperCaseA,upperCaseE,upperCaseIInt,upperCaseO,upperCaseU,upperCaseIrishA,upperCaseIrishE,upperCaseIrishI,upperCaseIrishO,upperCaseIrishU}; public static void main(String args[]) { Scanner sc=new Scanner(System.in); @@ -41,37 +42,40 @@ public static void main(String args[]) { } public String wordToLowerCase(String word,String language, String[] langWithNoLowerCase) { - if(isLanguage_with_no_lowerCase(langWithNoLowerCase, language)) + if(isLanguageWithNoLowerCase(langWithNoLowerCase, language)) return word; Locale locale1 = Locale.forLanguageTag(language); String lower1 = word.toLowerCase(locale1); - if(language.startsWith(turkish_lang) || language.startsWith(azerbaijani_lang)) + if(language.startsWith(turkishLang) || language.startsWith(azerbaijaniLang)) { - if(word.contains(upper_Case_I)) + if(word.contains(upperCaseI)) { - word.replaceAll(upper_Case_I,latin_Dotless_I ); + word.replaceAll(upperCaseI,latinDotlessI ); lower1 = word.toLowerCase(locale1); } } - else if(language.startsWith(irish_lang)) + else if(language.startsWith(irishLang)) { - if((word.charAt(0) == lowerCase_n || word.charAt(0) == lowerCase_t) && - (word.charAt(1) == upperCase_A || word.charAt(1) == upperCase_E || - word.charAt(1) == upperCase_I || word.charAt(1) == upperCase_O|| - word.charAt(1) == upperCase_U || word.charAt(1) == upperCase_Irish_A || - word.charAt(1) == upperCase_Irish_E || word.charAt(1) == upperCase_Irish_I || - word.charAt(1) == upperCase_Irish_O || word.charAt(1) == upperCase_Irish_U)) + if((word.charAt(0) == lowerCaseN || word.charAt(0) == lowerCaseT)) { + + for(Integer vowel:vowels) + { + if(word.charAt(1) == vowel) + { lower1 = lower1.substring(0,1) +"-" + lower1.substring(1); - } + break; + } + + } } } return lower1; } - boolean isLanguage_with_no_lowerCase(String []langWithNoLowerCase,String language) + boolean isLanguageWithNoLowerCase(String []langWithNoLowerCase,String language) { for(String noLowerCaselang:langWithNoLowerCase) { From 4f4e8da1153706bd6ecdeabc137ff85a76b10a06 Mon Sep 17 00:00:00 2001 From: MVR9999 <57259592+MVR9999@users.noreply.github.com> Date: Tue, 21 Feb 2023 22:56:39 -0600 Subject: [PATCH 4/5] Add files via upload --- S23/mvr9999/TestCasesJunit.java | 133 ++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 S23/mvr9999/TestCasesJunit.java diff --git a/S23/mvr9999/TestCasesJunit.java b/S23/mvr9999/TestCasesJunit.java new file mode 100644 index 00000000..7e0bd1ea --- /dev/null +++ b/S23/mvr9999/TestCasesJunit.java @@ -0,0 +1,133 @@ +package main; + +import static org. junit.Assert.*; + +import org.junit.Test; + +import com.firstspringproject.Controllers.ConvertToLowerCase; + +public class TestCasesJunit { + + ConvertToLowerCase obj = new ConvertToLowerCase(); + String langWithNoLowerCase[] = {"zh", "ja", "th"}; + + @Test + public void testcase1() { + assertEquals("hello", obj.wordToLowerCase("HELLO","en",langWithNoLowerCase)); + } + + @Test + public void testcase2() { + assertEquals("world", obj.wordToLowerCase("WORLD","en-US",langWithNoLowerCase)); + } + + @Test + public void testcase3() { + assertEquals("camel", obj.wordToLowerCase("cAmEl","en-IE",langWithNoLowerCase)); + } + + @Test + public void testcase4() { + assertEquals("---ok", obj.wordToLowerCase("---OK","en-Latn",langWithNoLowerCase)); + } + + @Test + public void testcase5() { + assertEquals("t-acht", obj.wordToLowerCase("tAcht","ga",langWithNoLowerCase)); + } + + @Test + public void testcase6() { + assertEquals("t-acht", obj.wordToLowerCase("tACHT","ga",langWithNoLowerCase)); + } + + @Test + public void testcase7() { + assertEquals("tacht", obj.wordToLowerCase("TACHT","ga",langWithNoLowerCase)); + } + + @Test + public void testcase8() { + assertEquals("n-athair", obj.wordToLowerCase("nAthair","ga",langWithNoLowerCase)); + } + + @Test + public void testcase9() { + assertEquals("n-athair", obj.wordToLowerCase("nATHAIR","ga",langWithNoLowerCase)); + } + + @Test + public void testcase10() { + assertEquals("nathair", obj.wordToLowerCase("NATHAIR","ga",langWithNoLowerCase)); + } + + @Test + public void testcase11() { + assertEquals("t-othair", obj.wordToLowerCase("tOthair","ga",langWithNoLowerCase)); + } + + @Test + public void testcase12() { + assertEquals("t-ethair", obj.wordToLowerCase("tETHAIR","ga",langWithNoLowerCase)); + } + + @Test + public void testcase13() { + assertEquals("t-ithair", obj.wordToLowerCase("tITHAIR","ga",langWithNoLowerCase)); + } + + @Test + public void testcase14() { + assertEquals("n-óg", obj.wordToLowerCase("nÓg","ga-IE",langWithNoLowerCase)); + } + + @Test + public void testcase15() { + assertEquals("nõg", obj.wordToLowerCase("nÕg","ga-IE",langWithNoLowerCase)); + } + + @Test + public void testcase16() { + assertEquals("对不起", obj.wordToLowerCase("对不起","zh",langWithNoLowerCase)); + } + + @Test + public void testcase17() { + assertEquals("ごめんなさい", obj.wordToLowerCase("ごめんなさい","ja",langWithNoLowerCase)); + } + + @Test + public void testcase18() { + assertEquals("kasım", obj.wordToLowerCase("KASIM","az",langWithNoLowerCase)); + } + + @Test + public void testcase19() { + assertEquals("kasim", obj.wordToLowerCase("KASIM","en",langWithNoLowerCase)); + } + + @Test + public void testcase20() { + assertEquals("πόλης", obj.wordToLowerCase("ΠΌΛΗΣ","el",langWithNoLowerCase)); + } + + @Test + public void testcase21() { + assertEquals("官话", obj.wordToLowerCase("官话","zh-Hans",langWithNoLowerCase)); + } + + @Test + public void testcase22() { + assertEquals("ภาษาไทย", obj.wordToLowerCase("ภาษาไทย","th",langWithNoLowerCase)); + } + + @Test + public void testcase23() { + assertEquals("πόλης", obj.wordToLowerCase("ΠΌΛΗΣ","el-GR",langWithNoLowerCase)); + } + + @Test + public void testcase24() { + assertEquals("πόλησπόλης", obj.wordToLowerCase("ΠΌΛΗΣΠΌΛΗΣ","el-GR",langWithNoLowerCase)); + } +} From d401e77e53774603c78fce1cb3134c383625b904 Mon Sep 17 00:00:00 2001 From: MVR9999 <57259592+MVR9999@users.noreply.github.com> Date: Wed, 22 Feb 2023 08:56:07 -0600 Subject: [PATCH 5/5] triangle testcases --- S23/mvr9999/myers.tsv | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 S23/mvr9999/myers.tsv diff --git a/S23/mvr9999/myers.tsv b/S23/mvr9999/myers.tsv new file mode 100644 index 00000000..b109c3cb --- /dev/null +++ b/S23/mvr9999/myers.tsv @@ -0,0 +1,16 @@ +{"a" : 3, "b" : 4, "c" : 5} scalene +{"a" : 3, "b" : 3, "c" : 1} isosceles +{"a" : 3, "b" : 4, "c" : 100} error + +{"a" : 4, "b" : 4, "c" : 4} equilateral +{"a" : 2, "b" : 2, "c" : 5} error +{"a" : 0, "b" : 4, "c" : 5} error +{"a" : -3, "b" : 4, "c" : 5} error +{"a" : 3.5, "b" : 4.5, "c" : 5.5} error +{"a" : 1000, "b" : 2000, "c" : 1000} isosceles +{"a" : 4, "b" : 5, "c" : 6} scalene +{"a" : 1, "b" : 1, "c" : 1} equilateral +{"a" : "", "b" : 4, "c" : 2} error +{"a" : 1, "b" : null, "c" : 4} error + +