From fac9a6d035a3935e8310aebe3a5e3f608fcdc6cc Mon Sep 17 00:00:00 2001 From: Pedram-Mehrdad Date: Sun, 3 Mar 2024 22:25:29 +0330 Subject: [PATCH] project filesadded --- Answers/40230112126/.idea/.gitignore | 3 + Answers/40230112126/.idea/.name | 1 + Answers/40230112126/.idea/compiler.xml | 13 + Answers/40230112126/.idea/dbnavigator.xml | 406 ++++++++++++++++++ Answers/40230112126/.idea/encodings.xml | 7 + Answers/40230112126/.idea/jarRepositories.xml | 20 + .../.idea/libraries/junit_jupiter.xml | 17 + Answers/40230112126/.idea/misc.xml | 14 + Answers/40230112126/.idea/uiDesigner.xml | 124 ++++++ Answers/40230112126/.idea/vcs.xml | 7 + Answers/40230112126/pom.xml | 38 ++ .../40230112126/src/main/java/Advanced.java | 63 +++ Answers/40230112126/src/main/java/Warmup.java | 60 +++ .../40230112126/src/test/java/StringTest.java | 41 ++ .../40230112126/target/classes/Advanced.class | Bin 0 -> 2070 bytes .../40230112126/target/classes/Warmup.class | Bin 0 -> 1771 bytes .../target/test-classes/StringTest.class | Bin 0 -> 2296 bytes 17 files changed, 814 insertions(+) create mode 100644 Answers/40230112126/.idea/.gitignore create mode 100644 Answers/40230112126/.idea/.name create mode 100644 Answers/40230112126/.idea/compiler.xml create mode 100644 Answers/40230112126/.idea/dbnavigator.xml create mode 100644 Answers/40230112126/.idea/encodings.xml create mode 100644 Answers/40230112126/.idea/jarRepositories.xml create mode 100644 Answers/40230112126/.idea/libraries/junit_jupiter.xml create mode 100644 Answers/40230112126/.idea/misc.xml create mode 100644 Answers/40230112126/.idea/uiDesigner.xml create mode 100644 Answers/40230112126/.idea/vcs.xml create mode 100644 Answers/40230112126/pom.xml create mode 100644 Answers/40230112126/src/main/java/Advanced.java create mode 100644 Answers/40230112126/src/main/java/Warmup.java create mode 100644 Answers/40230112126/src/test/java/StringTest.java create mode 100644 Answers/40230112126/target/classes/Advanced.class create mode 100644 Answers/40230112126/target/classes/Warmup.class create mode 100644 Answers/40230112126/target/test-classes/StringTest.class diff --git a/Answers/40230112126/.idea/.gitignore b/Answers/40230112126/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Answers/40230112126/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Answers/40230112126/.idea/.name b/Answers/40230112126/.idea/.name new file mode 100644 index 0000000..296aa65 --- /dev/null +++ b/Answers/40230112126/.idea/.name @@ -0,0 +1 @@ +Advanced.java \ No newline at end of file diff --git a/Answers/40230112126/.idea/compiler.xml b/Answers/40230112126/.idea/compiler.xml new file mode 100644 index 0000000..69cd7fc --- /dev/null +++ b/Answers/40230112126/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112126/.idea/dbnavigator.xml b/Answers/40230112126/.idea/dbnavigator.xml new file mode 100644 index 0000000..ac5f94f --- /dev/null +++ b/Answers/40230112126/.idea/dbnavigator.xml @@ -0,0 +1,406 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112126/.idea/encodings.xml b/Answers/40230112126/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/Answers/40230112126/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Answers/40230112126/.idea/jarRepositories.xml b/Answers/40230112126/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/Answers/40230112126/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112126/.idea/libraries/junit_jupiter.xml b/Answers/40230112126/.idea/libraries/junit_jupiter.xml new file mode 100644 index 0000000..965272a --- /dev/null +++ b/Answers/40230112126/.idea/libraries/junit_jupiter.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112126/.idea/misc.xml b/Answers/40230112126/.idea/misc.xml new file mode 100644 index 0000000..e2044d1 --- /dev/null +++ b/Answers/40230112126/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112126/.idea/uiDesigner.xml b/Answers/40230112126/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/Answers/40230112126/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112126/.idea/vcs.xml b/Answers/40230112126/.idea/vcs.xml new file mode 100644 index 0000000..64713b8 --- /dev/null +++ b/Answers/40230112126/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Answers/40230112126/pom.xml b/Answers/40230112126/pom.xml new file mode 100644 index 0000000..6803a74 --- /dev/null +++ b/Answers/40230112126/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/40230112126/src/main/java/Advanced.java b/Answers/40230112126/src/main/java/Advanced.java new file mode 100644 index 0000000..5ea8f5c --- /dev/null +++ b/Answers/40230112126/src/main/java/Advanced.java @@ -0,0 +1,63 @@ +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){ + sentence = sentence.replace(word, newWord); + return sentence; + } + + /** + * 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){ + firstName = firstName.toLowerCase(); + String firstLetterName = firstName.substring(0,1); //extracting the first word. + firstName = firstLetterName.toUpperCase() + firstName.substring(1); + + // first name is uppercase first word + rest of the word. + + boolean check = lastName.isBlank(); + if (check==false) { + lastName = lastName.toLowerCase(); + String firstLetterLastName = lastName.substring(0, 1); + lastName = firstLetterLastName.toUpperCase() + lastName.substring(1); + + String fullName = firstName + " " + lastName; + return fullName; + } + else + return firstName; + } + + /** + * 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) { + String answer=""; + for (int i=0 ; i words.length) { + String errorPrompt = "Number = " + number + "is out Of Bound"; + return errorPrompt; + } else { + return words[number - 1]; + } + } + /** + * 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) { + int odd=0; + int even=0; + + for(int i=0; i < number.length(); i++) { + if(number.charAt(i) % 2 == 1) + odd++; + else{ + even++; + } + } + + if (searchForEven == true) + return even; + else { + return odd; + } + } + + /** + * @param wordA --> first word + * @param wordB --> second word + * @return The word that is first in alphabet column + */ + public String firstWord(String wordA, String wordB) { + int result = wordA.compareToIgnoreCase(wordB); + if (result > 0) + return wordB; + else { + if (result < 0) + return wordA; + else { + return "identical words!"; + } + } + } +} diff --git a/Answers/40230112126/src/test/java/StringTest.java b/Answers/40230112126/src/test/java/StringTest.java new file mode 100644 index 0000000..3e13bf7 --- /dev/null +++ b/Answers/40230112126/src/test/java/StringTest.java @@ -0,0 +1,41 @@ +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("Tem", 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/40230112126/target/classes/Advanced.class b/Answers/40230112126/target/classes/Advanced.class new file mode 100644 index 0000000000000000000000000000000000000000..847274223fa465deeabc7b886c27efc125cfe2ba GIT binary patch literal 2070 zcmaJ?T~`}b6y29hK07H$8(Jz~tv~}w0gFW?6@^qJbpm4eQ0hmAWJ;zCGjV1@SAF(J zxO{OfUwo}ExE2ro0AGFZU-$!DtLna)DTGCkEN;#{_uPH=+2@{{-~T!O4ZwTYO`!{s zI2098!~}Yt>WBKYrQ3VcYr9X4sxJ_`Z`!86AP~t;Y^9JuGLDprOHj{*SA5sB_XOgu z(XjNYA@CrpouU=%x?3^6X&QFbC|u;9Xj=&I3i80qD!S1laLIQx=b7Oab&v2@vloQ- zsxHcPvZc}m;e9Huh3K1&Mu09)?Uyh&1Txu9J9{bLfQms330ynS_l=@s zS9O2e^y{=dU$=cv;GK2}!i>)6cmc5y6*qBn4>*X|DhZoIG>fTG6mQ#}#A?cWJ+oq&$e4ux9zwGx@CUL%e$%{aNm_DrtA5d;roWG z>7E~W6Hl6!6`09ZK~EILGrTyy5*Ry|WGC)%JQf)G|4>RFB+8zBlW(g0Q`o9}RXNVew&ORO7SYLH zA%3CJg||4$Wgvok9MvEIb9kFGJ|B3Oqujj72!-FtT>j1x;#%$nCjo$b!GSd5xZDDn z3<5(CZoxbXE#M^X(~{9iKK%tk3M^nKJmN3T<6K+M9U-mdBFYh7TjgPy9IflecpcF4 zM;M+{GRhCg(@dB1t*H5Ef0S|glels&e~dSP`B;DKMT=^rmFpCLHGu0BrJuRpAmk9` z8pb$AkfSw=TPR`_8pg23cTH-tLQ=CB!22W|IDkv^&8I+kd45&c6V z$rNv51`jw>u*~%nHjk&w0ch~R;|e{xwuuJn$UBMXC6U|gyFgo)hX5hmx9+@SJU z8qtiBiT(&RpHYr61(d&wh@b!cBcBU4FeGs2Wp#p-$9W`pBO z^xY%LW!6Qex++Nx4ES0Qc}P zi3p+wv=ns21je75$L4a!v=5fI_n*q9FA%$H*_K}wh|U)u#Ss?}g(Q*~F_22(5=P&t z+VNe>J`m8oZpUKv+{tfd$U_`pE<34mLhAPv8 z?AgR4Z)rElC1wZAILtbS7093yLk1&oX~#F4hnr?MU~J%qz^Kz|-9MIg&FK-4G$)3* z^|(lAVG+QSrrT_9IIgN;>@mkf1X?A7K;ntzdj1||3)~)pG^l0BF6hfx>)+R@(Uo4W zLo<>)PS0)14NFa7BsBWE+LoN9?JhHx>hT$CtQoU_yyBu>GX4&iT>vRNc0vTkDvfCp`lVf!P7c z!;~1<5}5k`RE{B(jcfcw_%jDIa7c*pI?cCb-UaXa!k-X-@F9X3Uez-Ao#izZCg5Yt z1+jS)8BxVQAWA4;x|BA~kl4y;zao)adi6U-b1yLl+|eer)1{o&T0Lc2G=QE6N)j+I zf;7RiJjU`&R;@naT9$bWD3K?D`%Tr;B4diwG?s9kG!5j){syyG7)>DZ57Gu!lT5lv zppfBfCdRm2j#i^(En3zydg%;Te#2BLqo3ib-qn6V;v_1bBX**R6J0$2_pcmdv5fX2 z|ALhv=>;BH;8_+SJ)Mm&lQPdQk|~g4j^t)YW0rmA0wGm)jWc$ORFy;Jw?fLK9||cm z`Y913th&uS<>d-KhH^P2 fbaMTiuMvEKHQwW7wa)JYe9bpCfp4&hZA|_L0G)=U literal 0 HcmV?d00001 diff --git a/Answers/40230112126/target/test-classes/StringTest.class b/Answers/40230112126/target/test-classes/StringTest.class new file mode 100644 index 0000000000000000000000000000000000000000..9836ff13c3d42a64e25294e41e20bc1363e513d1 GIT binary patch literal 2296 zcma)63sclq7(L;&aZLe(RVknsm8Y%vKx>Oy7s~SJ0u?A*?ZXE43ZdEDHOWHJzF+^R zGZme7raz!Rs?&3m$gXrd<1%D&zTA7x_nq&4_wRrH_zS=-{F+4*nlosz(26z#o!ici zGv+z|=GfBuw%mvewB2-lH@a=0d3acSIh;2j zRIoX=U1i05R@_JiV@|~#%Y~r~B3JpL0n3TO^rNcd5xyjpm^M)-lSW3?Obi<65sTIG zx(viEF)rLtsA?pZ9*Rj-^-Cs(4Rp*(&r>2FsIr)6FHDRYXdSYEnc!bQ5E zN~P%?=}&PZb2MEhQGJVI&q+BqpU;bjrGp z1p}uJEncInEUO?gvBZ+<;9V~MKPr7pS1hdJqx6VPNk3HdeEyYuctvN5?ETzOSxl)C z2Pp0RJ$AY-xKXK?_=Hx)FQ2hx$q{*A;OMgQMNvATCuyg{HNg@++@RmPGPmMQ@98q6 zg@?ME9li?6j^{q6l(x&nmTrvNaAsB36Ps2mOtD;3KnAk~=2hRj!v_dl1g6qp4$%)7eGj#?!b^;L#`-nC7r!;z=R^0kw%_EU8I#?MXoiqCc~23q*nM#>EK zh^%Bg9^(m-fv@?kDW<;5b(;E&eRA}7WbN*jee^sh9EjmiCV_|Pv!p(X(B=9hqD*QFbca)`a(nL z?+>J(q|!P2ddz>rzP^ulb(yzge8;|>;>j3K+V7`0ALG0|o8VePC)gj|txon!;3O{L z6z-tAE~#9@q<%O^sz?TH{eV4BkuJMnFWMjOV_B!Q7Dqm|@7tdyk(zMQ-(J?=hx2Sf ztpNiK1%EscTuEK%w?B{Rzp&T$QPOgoF?Q{If)9)Jv&yrq@?4!*e?zgK4#bwyGuvl> j8Izayp|n&OqiTW<3k|ZrL+tNxolsvxp`U476Mp#@K_>X1 literal 0 HcmV?d00001