diff --git a/Answers/40230112134/.idea/.gitignore b/Answers/40230112134/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/Answers/40230112134/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/Answers/40230112134/.idea/compiler.xml b/Answers/40230112134/.idea/compiler.xml
new file mode 100644
index 0000000..69cd7fc
--- /dev/null
+++ b/Answers/40230112134/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/.idea/dbnavigator.xml b/Answers/40230112134/.idea/dbnavigator.xml
new file mode 100644
index 0000000..ac5f94f
--- /dev/null
+++ b/Answers/40230112134/.idea/dbnavigator.xml
@@ -0,0 +1,406 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/.idea/encodings.xml b/Answers/40230112134/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/Answers/40230112134/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/.idea/jarRepositories.xml b/Answers/40230112134/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/Answers/40230112134/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/.idea/libraries/junit_jupiter.xml b/Answers/40230112134/.idea/libraries/junit_jupiter.xml
new file mode 100644
index 0000000..965272a
--- /dev/null
+++ b/Answers/40230112134/.idea/libraries/junit_jupiter.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/.idea/misc.xml b/Answers/40230112134/.idea/misc.xml
new file mode 100644
index 0000000..82dbec8
--- /dev/null
+++ b/Answers/40230112134/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/.idea/uiDesigner.xml b/Answers/40230112134/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/Answers/40230112134/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/pom.xml b/Answers/40230112134/pom.xml
new file mode 100644
index 0000000..6803a74
--- /dev/null
+++ b/Answers/40230112134/pom.xml
@@ -0,0 +1,38 @@
+
+
+ 4.0.0
+
+ org.example
+ StringMaster
+ 1.0-SNAPSHOT
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+
+
+ org.junit
+ junit-bom
+ 5.8.2
+ pom
+ import
+
+
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/src/main/java/Advanced.java b/Answers/40230112134/src/main/java/Advanced.java
new file mode 100644
index 0000000..4a49203
--- /dev/null
+++ b/Answers/40230112134/src/main/java/Advanced.java
@@ -0,0 +1,157 @@
+import java.util.Objects;
+
+public class Advanced {
+
+ /**
+ * Goal : Changing a Sentence Content
+
+ * In this function, you have a sentence, a word & a newWord as Entry
+ * You have to search the sentence to find the word that you were given as input and change it with the newWord
+
+ */
+ public String wordCensor(String sentence, String word, String newWord)
+ {
+ char[] newsen = new char[sentence.length()-word.length()+newWord.length()];
+ int z=0;
+ char[] sentence1 = sentence.toCharArray();
+ char[] W = word.toCharArray();
+ char[] N = newWord.toCharArray();
+ for (int i = sentence.length()-1 ; i > 0 ; i--)
+ {
+ if (sentence1[i] == ' ')
+ {
+ z=i;
+ for (int j = 0; j < i; j++)
+ {
+ newsen[j] = sentence1[j];
+ }
+ break;
+ }
+ }
+ z++;
+ for (int i = 0; i < newWord.length(); i++,z++)
+ {
+ newsen[z] = N[i];
+ }
+ newsen[sentence.length()-word.length()-1]=' ';
+ String javab = new String(newsen);
+ return javab;
+ }
+
+ /**
+ * In this function You have a firstName and a lastName as Entry and you have to normalize them as a fullName
+ * @param firstName is a first name with irregular letters (example : hARry)
+ * @param lastName is a last name with irregular letters (example : pOtTeR)
+ * @return fullName is a normal full name that just the first letter of firstName & lastName is Capitalized (example : Harry Potter)
+ */
+ public String normalizingName(String firstName, String lastName)
+
+ {
+
+ char[] F = firstName.toCharArray();
+ char[] L = lastName.toCharArray();
+ if (F[0]>96 && F[0]<123)
+ {
+ F[0] = (char) (F[0] - 32);
+ }
+ if (L[0]>96 && L[0]<123)
+ {
+ L[0] = (char) (L[0] - 32);
+ }
+ for (int i = 1; i < firstName.length(); i++)
+ {
+ if (F[i]>64 && F[i]<91)
+ {
+ F[i] = (char) (F[i] + 32);
+ }
+ }
+ for (int i = 1; i < lastName.length(); i++)
+ {
+ if (L[i]>64 && L[i]<91)
+ {
+ L[i] = (char) (L[i] + 32);
+ }
+ }
+ int j=1,z=0,x=0;
+ for (int i = 0; i < firstName.length(); i++)
+ {
+ if (!((F[i]>64 && F[i]<91)||(F[i]>96 && F[i]<123)))
+ {
+ while (j < firstName.length())
+ {
+ F[j]=F[(j+1)];
+ j++;
+ }
+ j=i+1;
+ z++;
+ }
+ }
+ char[] F1 = new char[firstName.length()-z];
+ for (int i = 0; i < firstName.length()-z; i++)
+ {
+ F1[i]=F[i];
+ }
+ j=1;
+ for (int i = 0; i < lastName.length(); i++)
+ {
+ if (!((L[i]>64 && L[i]<91)||(L[i]>96 && L[i]<123)))
+ {
+ while (j < lastName.length())
+ {
+ L[j]=L[(j+1)];
+ j++;
+ }
+ j=i+1;
+ x++;
+ }
+ }
+ char[] L1 = new char[lastName.length()-x];
+ for (int i = 0; i < lastName.length()-x; i++)
+ {
+ L1[i]=L[i];
+ }
+// int z=0;
+// for (int i = 0; i < firstName.length(); i++)
+// {
+// if (F[i])
+// }
+ String FF = new String(F1);
+ String LL = new String(L1);
+ char[] g = new char[1];
+ g[0]=' ';
+ if (L[0] == g[0])
+ {
+ FF=FF;
+ }
+ else
+ {
+ FF = FF + " " + LL;
+ }
+ return FF;
+
+ }
+
+ /**
+ * Removing repeated letter in a word
+ * @param word This input could have Consecutive repeated letters or not
+ * @return if word contains Consecutive repeated letters, one of the repeated letters should be omitted
+ */
+ public String doubleChar(String word)
+ {
+ char[] W = word.toCharArray();
+ char[] neww = new char[word.length()];
+// String newword="";
+ for (int i = 0; i < word.length() ; i++)
+ {
+ if (W[i] == W[(i+1)])
+ {
+ for (int k = 0; k < i; k++)
+ {
+ neww[k] = W[k];
+ }
+ }
+ }
+ String new1 = new String(W);
+ return new1;
+ }
+}
\ No newline at end of file
diff --git a/Answers/40230112134/src/main/java/Warmup.java b/Answers/40230112134/src/main/java/Warmup.java
new file mode 100644
index 0000000..6242517
--- /dev/null
+++ b/Answers/40230112134/src/main/java/Warmup.java
@@ -0,0 +1,121 @@
+public class Warmup {
+
+ /**
+ * Goal : Simple Introduction To Strings
+ * In the first function, your inputs are a number and a sentence
+ * @return is the number th word of the sentence
+ */
+ public String wordFinder(String sentence, int number)
+ {
+
+ char[] sen = sentence.toCharArray();
+ char[][] bakhsh = new char[50][50];
+ int j=0;
+ int k=0;
+ for (int i = 0; i < sentence.length() ; i++)
+ {
+ if (sen[i] == ' ')
+ {
+ j++;
+ k=0;
+ }
+ bakhsh[j][k]=sen[i];
+ k++;
+ }
+ char[] J = new char[100];
+ int z;
+ int i = 0;
+ if ((number-1) > j)
+ {
+ char[] j1 = {'N', 'u', 'm', 'b', 'e', 'r', ' ', '=', ' ', ' ', ' ', 'i', 's', ' ', 'o', 'u', 't', ' ', 'O', 'f', ' ', 'B', 'o', 'u', 'n', 'd', ' '};
+ J = j1;
+ J[9]= (char) number;
+ }
+ else
+ {
+ for ( i = 0; bakhsh[number-1][i] != '\0'; i++)
+ {
+ J[i] = bakhsh[number-1][i];
+ }
+ }
+ z=i;
+ char[] J1 = new char[z];
+ for (int l = 0; l <= z; l++)
+ {
+ J1[l] = J[l];
+ }
+ String dd = new String(J1);
+// System.out.println(dd);
+// System.out.println("dvds");
+ return dd;
+ }
+
+ /**
+ * Goal : Basic introduction to Strings & using foreach
+ * @param number is in String type
+ * @param searchForEven is a boolean entry
+ * @return if searchForEven is true ? return the number of even numbers : return the number of odd numbers
+ */
+ public int oddEvenCounter(String number, boolean searchForEven)
+ {
+ char[] num = number.toCharArray();
+ int e=0,O=0;
+ for (int i = 0; i < number.length() ; i++)
+ {
+ if (num[i] == '0' || num[i] == '2' || num[i] == '4' || num[i] == '6'|| num[i] == '8')
+ {
+ e ++;
+ }
+ else
+ {
+ O ++;
+ }
+ }
+ if (searchForEven == true)
+ {
+ return e;
+ }
+ else
+ {
+ return O;
+ }
+ }
+
+ /**
+ * @param wordA --> first word
+ * @param wordB --> second word
+ * @return The word that is first in alphabet column
+ */
+ public String firstWord(String wordA, String wordB)
+ {
+// boolean flag = true;
+ char[] A = wordA.toCharArray();
+ char[] B = wordB.toCharArray();
+// int[] a = new int[A.length];
+// int[] b = new int[B.length];
+// for (int i = 0; i < A.length; i++) {
+// a[i]=A[i];
+// }
+// for (int i = 0; i < A.length; i++) {
+// b[i]=B[i];
+// }
+ for (int i = 0; i < wordA.length() && i < wordB.length(); i++)
+ {
+ if ( (int)B[i] < (int)A[i] )
+ {
+// flag = false;
+ return wordB;
+ }
+
+ }
+ return wordA;
+// if (flag == true)
+// {
+// return wordA;
+// }
+// else
+// {
+// return wordB;
+// }
+ }
+}
diff --git a/Answers/40230112134/src/test/java/StringTest.java b/Answers/40230112134/src/test/java/StringTest.java
new file mode 100644
index 0000000..cf6b070
--- /dev/null
+++ b/Answers/40230112134/src/test/java/StringTest.java
@@ -0,0 +1,42 @@
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class StringTest {
+
+ Warmup warmup = new Warmup();
+ Advanced advanced = new Advanced();
+ @Test
+ public void wordFinder_test(){
+ assertEquals("Happy", warmup.wordFinder("Happy New Term", 1));
+ assertEquals(" Number = 4 is out Of Bound", warmup.wordFinder("Hello From Java", 4));
+ }
+ @Test
+ public void oddEvenCounter_test(){
+ assertEquals(2, warmup.oddEvenCounter("43512", true));
+ assertEquals(0, warmup.oddEvenCounter("00000", false));
+ assertEquals(4, warmup.oddEvenCounter("1111", false));
+ }
+ @Test
+ public void firstWord_test()
+ {
+ assertEquals("Fred", warmup.firstWord("George", "Fred"));
+ assertEquals("Harrold", warmup.firstWord("Harry", "Harrold"));
+ assertEquals("Ali", warmup.firstWord("Ali", "Alson"));
+ assertEquals(" ", warmup.firstWord(" ", "Albus"));
+ }
+ @Test
+ public void wordCensor_test(){
+ assertEquals("We should stop He Who Must Not Be Named", advanced.wordCensor("We should stop Voldemort", "Voldemort", "He Who Must Not Be Named"));
+ assertEquals("I'm Coding Java", advanced.wordCensor("I'm Coding cpp", "cpp", "Java"));
+ }
+ @Test
+ public void normalizingName_test(){
+ assertEquals("Ron Weasley", advanced.normalizingName("rOn", "weASlEy"));
+ assertEquals("Hogwart", advanced.normalizingName("hoGWart", " "));
+ }
+ @Test
+ public void doubleChar_test(){
+ assertEquals("Hary poter", advanced.doubleChar("Harry potter"));
+ assertEquals("Hary", advanced.doubleChar("Harrrry"));
+ }
+}
diff --git a/Answers/40230112134/src/untitled/.gitignore b/Answers/40230112134/src/untitled/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/Answers/40230112134/src/untitled/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/Answers/40230112134/src/untitled/.idea/encodings.xml b/Answers/40230112134/src/untitled/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/Answers/40230112134/src/untitled/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/src/untitled/.idea/misc.xml b/Answers/40230112134/src/untitled/.idea/misc.xml
new file mode 100644
index 0000000..82dbec8
--- /dev/null
+++ b/Answers/40230112134/src/untitled/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/src/untitled/.idea/vcs.xml b/Answers/40230112134/src/untitled/.idea/vcs.xml
new file mode 100644
index 0000000..4fce1d8
--- /dev/null
+++ b/Answers/40230112134/src/untitled/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/src/untitled/.idea/workspace.xml b/Answers/40230112134/src/untitled/.idea/workspace.xml
new file mode 100644
index 0000000..a374274
--- /dev/null
+++ b/Answers/40230112134/src/untitled/.idea/workspace.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1709538781161
+
+
+ 1709538781161
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/src/main/java/org/example/Main.java
+ 13
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/src/untitled/pom.xml b/Answers/40230112134/src/untitled/pom.xml
new file mode 100644
index 0000000..d69c9eb
--- /dev/null
+++ b/Answers/40230112134/src/untitled/pom.xml
@@ -0,0 +1,17 @@
+
+
+ 4.0.0
+
+ org.example
+ untitled
+ 1.0-SNAPSHOT
+
+
+ 17
+ 17
+ UTF-8
+
+
+
\ No newline at end of file
diff --git a/Answers/40230112134/src/untitled/src/main/java/org/example/Main.java b/Answers/40230112134/src/untitled/src/main/java/org/example/Main.java
new file mode 100644
index 0000000..a02700f
--- /dev/null
+++ b/Answers/40230112134/src/untitled/src/main/java/org/example/Main.java
@@ -0,0 +1,17 @@
+package org.example;
+
+//TIP To Run code, press or
+// click the icon in the gutter.
+public class Main {
+ public static void main(String[] args) {
+ //TIP Press with your caret at the highlighted text
+ // to see how IntelliJ IDEA suggests fixing it.
+ System.out.printf("Hello and welcome!");
+
+ for (int i = 1; i <= 5; i++) {
+ //TIP Press to start debugging your code. We have set one breakpoint
+ // for you, but you can always add more by pressing .
+ System.out.println("i = " + i);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Answers/40230112134/target/classes/Advanced.class b/Answers/40230112134/target/classes/Advanced.class
new file mode 100644
index 0000000..7a31e86
Binary files /dev/null and b/Answers/40230112134/target/classes/Advanced.class differ
diff --git a/Answers/40230112134/target/classes/Warmup.class b/Answers/40230112134/target/classes/Warmup.class
new file mode 100644
index 0000000..52744a6
Binary files /dev/null and b/Answers/40230112134/target/classes/Warmup.class differ
diff --git a/Answers/40230112134/target/test-classes/StringTest.class b/Answers/40230112134/target/test-classes/StringTest.class
new file mode 100644
index 0000000..3438944
Binary files /dev/null and b/Answers/40230112134/target/test-classes/StringTest.class differ
diff --git a/Base Structure/src/main/java/Advanced.java b/Base Structure/src/main/java/Advanced.java
index 4af5eae..7e08571 100644
--- a/Base Structure/src/main/java/Advanced.java
+++ b/Base Structure/src/main/java/Advanced.java
@@ -9,8 +9,33 @@ public class Advanced {
* You have to search the sentence to find the word that you were given as input and change it with the newWord
*/
- public String wordCensor(String sentence, String word, String newWord){
- return null;
+ public String wordCensor(String sentence, String word, String newWord)
+ {
+ char[] newsen = new char[sentence.length()-word.length()+newWord.length()];
+ int z=0;
+ char[] sentence1 = sentence.toCharArray();
+ char[] W = word.toCharArray();
+ char[] N = newWord.toCharArray();
+ for (int i = sentence.length()-1 ; i > 0 ; i--)
+ {
+ if (sentence1[i] == ' ')
+ {
+ z=i;
+ for (int j = 0; j < i; j++)
+ {
+ newsen[j] = sentence1[j];
+ }
+ break;
+ }
+ }
+ z++;
+ for (int i = 0; i < newWord.length(); i++,z++)
+ {
+ newsen[z] = N[i];
+ }
+ newsen[sentence.length()-word.length()-1]=' ';
+ String javab = new String(newsen);
+ return javab;
}
/**
@@ -19,8 +44,91 @@ public String wordCensor(String sentence, String word, String newWord){
* @param lastName is a last name with irregular letters (example : pOtTeR)
* @return fullName is a normal full name that just the first letter of firstName & lastName is Capitalized (example : Harry Potter)
*/
- public String normalizingName(String firstName, String lastName){
- return null;
+ public String normalizingName(String firstName, String lastName)
+
+ {
+
+ char[] F = firstName.toCharArray();
+ char[] L = lastName.toCharArray();
+ if (F[0]>96 && F[0]<123)
+ {
+ F[0] = (char) (F[0] - 32);
+ }
+ if (L[0]>96 && L[0]<123)
+ {
+ L[0] = (char) (L[0] - 32);
+ }
+ for (int i = 1; i < firstName.length(); i++)
+ {
+ if (F[i]>64 && F[i]<91)
+ {
+ F[i] = (char) (F[i] + 32);
+ }
+ }
+ for (int i = 1; i < lastName.length(); i++)
+ {
+ if (L[i]>64 && L[i]<91)
+ {
+ L[i] = (char) (L[i] + 32);
+ }
+ }
+ int j=1,z=0,x=0;
+ for (int i = 0; i < firstName.length(); i++)
+ {
+ if (!((F[i]>64 && F[i]<91)||(F[i]>96 && F[i]<123)))
+ {
+ while (j < firstName.length())
+ {
+ F[j]=F[(j+1)];
+ j++;
+ }
+ j=i+1;
+ z++;
+ }
+ }
+ char[] F1 = new char[firstName.length()-z];
+ for (int i = 0; i < firstName.length()-z; i++)
+ {
+ F1[i]=F[i];
+ }
+ j=1;
+ for (int i = 0; i < lastName.length(); i++)
+ {
+ if (!((L[i]>64 && L[i]<91)||(L[i]>96 && L[i]<123)))
+ {
+ while (j < lastName.length())
+ {
+ L[j]=L[(j+1)];
+ j++;
+ }
+ j=i+1;
+ x++;
+ }
+ }
+ char[] L1 = new char[lastName.length()-x];
+ for (int i = 0; i < lastName.length()-x; i++)
+ {
+ L1[i]=L[i];
+ }
+// int z=0;
+// for (int i = 0; i < firstName.length(); i++)
+// {
+// if (F[i])
+// }
+ String FF = new String(F1);
+ String LL = new String(L1);
+ char[] g = new char[1];
+ g[0]=' ';
+ if (L[0] == g[0])
+ {
+ FF=FF;
+ }
+ else
+ {
+ FF = FF + " " + LL;
+ }
+ return FF;
+
}
/**
@@ -28,8 +136,57 @@ public String normalizingName(String firstName, String lastName){
* @param word This input could have Consecutive repeated letters or not
* @return if word contains Consecutive repeated letters, one of the repeated letters should be omitted
*/
- public String doubleChar(String word) {
- return null;
- }
-}
+ public String doubleChar(String word)
+ {
+ char[] Word = word.toCharArray();
+// char[] neww = new char[word.length()];
+// int z=0;
+// for (int i = 0; i < word.length()-1 ; i++)
+// {
+// if ((i+1)==word.length())
+// {
+// neww[z+1] = W[i+1];
+// break;
+//// }
+// if (W[i] == W[(i+1)])
+// {
+// neww[z] = W[i];
+// z++;
+// i++;
+// }
+// else
+// {
+// neww[z] = W[i];
+// z++;
+// }
+// }
+// z++;
+// neww[z-1] = W[word.length()-1];
+// String new1 ="";
+// for (int i = 0; i < word.length(); i++)
+// {
+// if ( (neww[i]>64 && neww[i]<91) || (neww[i]>96 && neww[i]<123) || (neww[i]==' '))
+// {
+// new1 = String.valueOf(+ neww[i]);
+// }
+// }
+ int z=0;
+ for (int i = 0; i < word.length()-1; i++)
+ {
+ if (Word[i] == Word[i+1])
+ {
+ for (int j = i; j < word.length()-1 ; j++)
+ {
+ Word[j] = Word[j+1];
+ }
+ if(i second word
* @return The word that is first in alphabet column
*/
- public String firstWord(String wordA, String wordB) {
- return null;
+ public String firstWord(String wordA, String wordB)
+ {
+// boolean flag = true;
+ char[] A = wordA.toCharArray();
+ char[] B = wordB.toCharArray();
+// int[] a = new int[A.length];
+// int[] b = new int[B.length];
+// for (int i = 0; i < A.length; i++) {
+// a[i]=A[i];
+// }
+// for (int i = 0; i < A.length; i++) {
+// b[i]=B[i];
+// }
+ for (int i = 0; i < wordA.length() && i < wordB.length(); i++)
+ {
+ if ( (int)B[i] < (int)A[i] )
+ {
+// flag = false;
+ return wordB;
+ }
+
+ }
+ return wordA;
+// if (flag == true)
+// {
+// return wordA;
+// }
+// else
+// {
+// return wordB;
+// }
}
}
diff --git a/Base Structure/src/test/java/StringTest.java b/Base Structure/src/test/java/StringTest.java
index 3e13bf7..cf6b070 100644
--- a/Base Structure/src/test/java/StringTest.java
+++ b/Base Structure/src/test/java/StringTest.java
@@ -7,7 +7,7 @@ public class StringTest {
Advanced advanced = new Advanced();
@Test
public void wordFinder_test(){
- assertEquals("Tem", warmup.wordFinder("Happy New Term", 1));
+ assertEquals("Happy", warmup.wordFinder("Happy New Term", 1));
assertEquals(" Number = 4 is out Of Bound", warmup.wordFinder("Hello From Java", 4));
}
@Test
@@ -17,7 +17,8 @@ public void oddEvenCounter_test(){
assertEquals(4, warmup.oddEvenCounter("1111", false));
}
@Test
- public void firstWord_test(){
+ public void firstWord_test()
+ {
assertEquals("Fred", warmup.firstWord("George", "Fred"));
assertEquals("Harrold", warmup.firstWord("Harry", "Harrold"));
assertEquals("Ali", warmup.firstWord("Ali", "Alson"));
diff --git a/Base Structure/target/classes/Advanced.class b/Base Structure/target/classes/Advanced.class
index 3235fe8..ffc4c15 100644
Binary files a/Base Structure/target/classes/Advanced.class and b/Base Structure/target/classes/Advanced.class differ
diff --git a/Base Structure/target/classes/Warmup.class b/Base Structure/target/classes/Warmup.class
index 5c5b915..af78902 100644
Binary files a/Base Structure/target/classes/Warmup.class and b/Base Structure/target/classes/Warmup.class differ
diff --git a/Base Structure/target/test-classes/StringTest.class b/Base Structure/target/test-classes/StringTest.class
index 464d0c3..3438944 100644
Binary files a/Base Structure/target/test-classes/StringTest.class and b/Base Structure/target/test-classes/StringTest.class differ
diff --git a/untitled/.idea/workspace.xml b/untitled/.idea/workspace.xml
new file mode 100644
index 0000000..d416452
--- /dev/null
+++ b/untitled/.idea/workspace.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1709550335824
+
+
+ 1709550335824
+
+
+
+
\ No newline at end of file