Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triangle testcases #204

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions S23/mvr9999/AllTestCasesToLowerCase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.firstspringproject.Controllers;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.*;

public class AllTestCasesToLowerCase {

String turkishLang = "tr";
String azerbaijaniLang = "az";
String irishLang = "ga";
String latinDotlessI = "\u0131";

String upperCaseI = "I";
char lowerCaseT = 't';
char lowerCaseN = 'n';

// Ascii values of vowels
int upperCaseA = 65;
int upperCaseE = 69;
int upperCaseIInt = 73;
int upperCaseO = 79;
int upperCaseU = 85;

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
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();
}
AllTestCasesToLowerCase object = new AllTestCasesToLowerCase();
for(int i=0;i<words.length;i++)
{
String result = object.wordToLowerCase(words[i],lang[i],langWithNoLowerCase);
printWriter.println(words[i]+ " " + lang[i] +" "+result);
}
printWriter.close();
}
public String wordToLowerCase(String word,String language, String[] langWithNoLowerCase)
{
if(isLanguageWithNoLowerCase(langWithNoLowerCase, language))
return word;

Locale locale1 = Locale.forLanguageTag(language);

String lower1 = word.toLowerCase(locale1);
if(language.startsWith(turkishLang) || language.startsWith(azerbaijaniLang))
{
if(word.contains(upperCaseI))
{
word.replaceAll(upperCaseI,latinDotlessI );
lower1 = word.toLowerCase(locale1);
}
}
else if(language.startsWith(irishLang))
{
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 isLanguageWithNoLowerCase(String []langWithNoLowerCase,String language)
{
for(String noLowerCaselang:langWithNoLowerCase)
{
if(language.startsWith(noLowerCaselang))
return true;
}
return false;
}
}
88 changes: 88 additions & 0 deletions S23/mvr9999/ConvertToLowerCase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.firstspringproject.Controllers;

import java.util.*;

public class ConvertToLowerCase {

String turkishLang = "tr";
String azerbaijaniLang = "az";
String irishLang = "ga";
String latinDotlessI = "\u0131";

String upperCaseI = "I";
char lowerCaseT = 't';
char lowerCaseN = 'n';

// Ascii values of vowels
int upperCaseA = 65;
int upperCaseE = 69;
int upperCaseIInt = 73;
int upperCaseO = 79;
int upperCaseU = 85;

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);
System.out.println("Enter the word to be converted to lower case: ");
String word = sc.nextLine();
System.out.println("Enter the language of the word to be converted to lower case: ");
String language = sc.nextLine();
String langWithNoLowerCase[] = {"zh", "ja", "th"};

ConvertToLowerCase object = new ConvertToLowerCase();
String result = object.wordToLowerCase(word,language,langWithNoLowerCase);
System.out.println("Result : "+result);
}
public String wordToLowerCase(String word,String language, String[] langWithNoLowerCase)
{
if(isLanguageWithNoLowerCase(langWithNoLowerCase, language))
return word;

Locale locale1 = Locale.forLanguageTag(language);

String lower1 = word.toLowerCase(locale1);
if(language.startsWith(turkishLang) || language.startsWith(azerbaijaniLang))
{
if(word.contains(upperCaseI))
{
word.replaceAll(upperCaseI,latinDotlessI );
lower1 = word.toLowerCase(locale1);
}
}
else if(language.startsWith(irishLang))
{
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 isLanguageWithNoLowerCase(String []langWithNoLowerCase,String language)
{
for(String noLowerCaselang:langWithNoLowerCase)
{
if(language.startsWith(noLowerCaselang))
return true;
}
return false;
}

}
133 changes: 133 additions & 0 deletions S23/mvr9999/TestCasesJunit.java
Original file line number Diff line number Diff line change
@@ -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));
}
}
16 changes: 16 additions & 0 deletions S23/mvr9999/myers.tsv
Original file line number Diff line number Diff line change
@@ -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


24 changes: 24 additions & 0 deletions S23/mvr9999/result.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
HELLO en hello
WORLD en-US world
cAmEl en-IE camel
---OK en-Latn ---ok
tAcht ga t-acht
tACHT ga t-acht
TACHT ga tacht
nAthair ga n-athair
nATHAIR ga n-athair
NATHAIR ga nathair
tOthair ga t-othair
tETHAIR ga t-ethair
tITHAIR ga t-ithair
nÓg ga-IE n-óg
nÕg ga-IE nõg
对不起 zh 对不起
ごめんなさい ja ごめんなさい
KASIM az kasım
KASIM en kasim
ΠΌΛΗΣ el πόλης
官话 zh-Hans 官话
ภาษาไทย th ภาษาไทย
ΠΌΛΗΣ el-GR πόλης
ΠΌΛΗΣΠΌΛΗΣ el-GR πόλησπόλης