From 462c865473dc94da4a898b155bfcdc190740f40b Mon Sep 17 00:00:00 2001 From: arshiammz Date: Sun, 3 Mar 2024 14:01:55 +0330 Subject: [PATCH] Answers done. --- Answers/40230112117/.idea/.gitignore | 3 + Answers/40230112117/.idea/compiler.xml | 13 + Answers/40230112117/.idea/dbnavigator.xml | 406 ++++++++++++++++++ Answers/40230112117/.idea/encodings.xml | 7 + Answers/40230112117/.idea/jarRepositories.xml | 20 + .../.idea/libraries/junit_jupiter.xml | 17 + Answers/40230112117/.idea/misc.xml | 14 + Answers/40230112117/.idea/uiDesigner.xml | 124 ++++++ Answers/40230112117/pom.xml | 44 ++ .../40230112117/src/main/java/Advanced.java | 66 +++ Answers/40230112117/src/main/java/Warmup.java | 85 ++++ .../40230112117/src/test/java/StringTest.java | 41 ++ .../40230112117/target/classes/Advanced.class | Bin 0 -> 2398 bytes .../40230112117/target/classes/Warmup.class | Bin 0 -> 2642 bytes .../target/test-classes/StringTest.class | Bin 0 -> 2299 bytes 15 files changed, 840 insertions(+) create mode 100644 Answers/40230112117/.idea/.gitignore create mode 100644 Answers/40230112117/.idea/compiler.xml create mode 100644 Answers/40230112117/.idea/dbnavigator.xml create mode 100644 Answers/40230112117/.idea/encodings.xml create mode 100644 Answers/40230112117/.idea/jarRepositories.xml create mode 100644 Answers/40230112117/.idea/libraries/junit_jupiter.xml create mode 100644 Answers/40230112117/.idea/misc.xml create mode 100644 Answers/40230112117/.idea/uiDesigner.xml create mode 100644 Answers/40230112117/pom.xml create mode 100644 Answers/40230112117/src/main/java/Advanced.java create mode 100644 Answers/40230112117/src/main/java/Warmup.java create mode 100644 Answers/40230112117/src/test/java/StringTest.java create mode 100644 Answers/40230112117/target/classes/Advanced.class create mode 100644 Answers/40230112117/target/classes/Warmup.class create mode 100644 Answers/40230112117/target/test-classes/StringTest.class diff --git a/Answers/40230112117/.idea/.gitignore b/Answers/40230112117/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Answers/40230112117/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Answers/40230112117/.idea/compiler.xml b/Answers/40230112117/.idea/compiler.xml new file mode 100644 index 0000000..69cd7fc --- /dev/null +++ b/Answers/40230112117/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112117/.idea/dbnavigator.xml b/Answers/40230112117/.idea/dbnavigator.xml new file mode 100644 index 0000000..ac5f94f --- /dev/null +++ b/Answers/40230112117/.idea/dbnavigator.xml @@ -0,0 +1,406 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112117/.idea/encodings.xml b/Answers/40230112117/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/Answers/40230112117/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Answers/40230112117/.idea/jarRepositories.xml b/Answers/40230112117/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/Answers/40230112117/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112117/.idea/libraries/junit_jupiter.xml b/Answers/40230112117/.idea/libraries/junit_jupiter.xml new file mode 100644 index 0000000..965272a --- /dev/null +++ b/Answers/40230112117/.idea/libraries/junit_jupiter.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112117/.idea/misc.xml b/Answers/40230112117/.idea/misc.xml new file mode 100644 index 0000000..abc4263 --- /dev/null +++ b/Answers/40230112117/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112117/.idea/uiDesigner.xml b/Answers/40230112117/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/Answers/40230112117/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112117/pom.xml b/Answers/40230112117/pom.xml new file mode 100644 index 0000000..4d38f33 --- /dev/null +++ b/Answers/40230112117/pom.xml @@ -0,0 +1,44 @@ + + + 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 + + + org.jetbrains + annotations + RELEASE + compile + + + + \ No newline at end of file diff --git a/Answers/40230112117/src/main/java/Advanced.java b/Answers/40230112117/src/main/java/Advanced.java new file mode 100644 index 0000000..917f484 --- /dev/null +++ b/Answers/40230112117/src/main/java/Advanced.java @@ -0,0 +1,66 @@ +import java.lang.reflect.Array; +import java.util.Objects; + +public class Advanced { + public static void main(String[] args) { + + } + + + /** + * 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){ + String[] a = sentence.split(" "); + for (int i=0; i l) { + String x = "Number = "; + String y = String.valueOf(number); + String z = " is out Of Bound"; + String EROR = x+y+z ; + return EROR; + } + 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 even=0,odd=0; + int n = Integer.parseInt((number)); + while(n > 0){ + if((n%10)%2 == 0){ + even++; + }else{ + odd++; + } + n = n/10; + } + if(searchForEven){ + 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 la = wordA.length(); + int lb = wordB.length(); + int l_min; + String word_min; + //check kardan inke kodoom kotah tare + if (la > lb){ + l_min = lb; + word_min = wordB; + }else{ + l_min = la; + word_min = wordA; + } + //bray estefade az aski code lowercase kardam + String A = wordA.toLowerCase(); + String B = wordB.toLowerCase(); + Boolean check = true; + for (int i=0; i (int)B.charAt(i)) { + check = false; + B = B.substring(0,1).toUpperCase() + B.substring(1); + return wordB; + } + } + if (check){ + word_min = word_min.substring(0,1).toUpperCase() + word_min.substring(1); + return word_min; + } + return null; + } +} diff --git a/Answers/40230112117/src/test/java/StringTest.java b/Answers/40230112117/src/test/java/StringTest.java new file mode 100644 index 0000000..e17a535 --- /dev/null +++ b/Answers/40230112117/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("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/40230112117/target/classes/Advanced.class b/Answers/40230112117/target/classes/Advanced.class new file mode 100644 index 0000000000000000000000000000000000000000..aa5879cf268d682f57ac2c53b68055be556aab72 GIT binary patch literal 2398 zcma)8T~`xV6x}y7lL=u^8wffo7F*CnKrFSWL9LKt#RjyZ;77lPWPp({6K5t+efCGx zr>^BoU)z_s7G2AyzO--s4Snc;aMiZ^&IE}Dy9z6J&OP^>ea}Ao&P{&%d+RxX3wV@9 z0*VgRfQF>NzWdgOHCnaYmCkSPNC}AkG}7qQVHoJbp4YPG zL*H>%1hk-5b(noTSK5J$7bo)f+IXGXvaQK+Jrnu6Df9>+!}@y- z?8gCt{p;46UG&_t6)rmADy<;2+>i)oTM?Suw{My zf!+*N?A0;CR=nBmsk&3G*nS$rP-Ic3419nwHo0oME8%J+>x^7DZQvt}bD_Ly`ID4R z<$gt(cS;VYZ^?1(x%&E&?ccPPs`O+^UfHTHSiU3YO{W^JI+QhC+6I^)!n)=L=l@U#F%0u(Y>;WeJC$8FCG5H?&DsQhHMzS-z}5KzHrU z#mEvC6PENjvs`vovK>fW@4F)6Y?E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E@Zk;#ROJmh%rODIf*vKiXl9p4WLGi%6CSHO>6D6D zbJUU@sSb*MN>+`hn^7JGXB4iP-lCIpbvSIW5JJb7+(d|46>bzBN*Y$ArtS$G->JA| zuQ*F)Pf+;aA{aHYo>OE49`3G7IWXAeiecySrh9zcah6Jj{#~HU9o*%4YvI&`f>|Ma zcl(0-wSV^!ET2GpV=Om~Hda!>8a=>HH1iR~l6q;V7rU&nU-O5P-|L;`_#Ml^(hHFN6@`voBSz zZSZ36evuA0$HPz2T3?${nxA8TMy-!$w1kpS6WS&Y0vSD_uXi_xb7$7MFywD`!cP)` z##^JB+wJEUP8|Etgj!y+b?Bm}hnJiLbDObo9L9$jCyORD;2JH}kGoEb_aU=R(9$Ka zGH7XiM4u$phmUcCG&P*UB&HZ$&FkeRePK*u8+ zmh_UO)5`G}f7{T_`~NiBah9MY;lW_nZ6ayH4~V2Oi(5oh#e4QP;fI*>G(Pi*R3nAY zX(>J>e)GRZH4jolRYW15JN&o6?;x2<`oLCd1FeHy9Ma(y*}0$ zGN3J^F`_M_ho7S(6A7iG@n~Fmf`wE(x`9(&{`dq(L;iF^3xzjuW&`PjM&tY@`q_Rh zwVu%Yz=ZBUo^HqM+wuBNyxz6G8Wn4A9ws6i7<`15gt{H3?u4lcbzSTzY7U1;s+aWp zNbfxLlc8$*sh0tkeURn8$TAPH*uyOJC3;6#)KM1fGAzn`31j$%GXI`Bd&HTa81pk# z^$S(>k`4Hs%8|`k^_8mP3%}HdSWJV_D$>j_N1tr<)^_W*kS(`v3prX<#P<>=<75*y zF;6Q@d~4-=t$13_cM^}Wz!e%1Kg1#}ow$D>*1OcJRBbP`S7;J!s3Lfd-tb`Xf43o; v{A1?>!yh|&3VM6~fzrx-m$G-s`}9Tm{s3R&TO|Gk&}%yd literal 0 HcmV?d00001 diff --git a/Answers/40230112117/target/test-classes/StringTest.class b/Answers/40230112117/target/test-classes/StringTest.class new file mode 100644 index 0000000000000000000000000000000000000000..23a29266e22dbc3a8bbb796d02154ebed7b8af2f GIT binary patch literal 2299 zcma)6i&7Lv6g>mT4$A~^FbWFVs60&spD{s=3t5kSH2N&`<0NSWXOP9#tKW@D-uNw#hn~G%~tsV#vVpg=%?C z2I7XeEZk72Y9tmPiYZm~OD0APbk0i8Qz9Rzvbe)$m>6UAmoHtpa8XzKmW8)*o+hYL zX=Ypc)7;1u4IFJy?fua?UEGAO>;hRv=H_%3mpGl!KND9Bv|QlN#58uToZ)RS=n2WJz`KE*JkFl|HA-7FO_adcvlqA1Zo&=e2xzO=pVi{oHU_Osf)a zP}=)@>~vjly;3ppDXoeppR;Aj5qV&seM$MED4o!gwA105V38iK)9)RbTlQvlbs5sa zL*30zUj=2yb01Sm+ht;te$1*3UfD>{^eyh&RJVC=>6OR2*|c3zQ9NrVd|m^t&mSKR;Z4+N^{m%!N zBlOeBF#}!`v~t`bnnyEdz=^TvFvk8w=H7F(Jwuk$E>7)d=>CnLoA5Qq4lV{-_}5Cx z40egEWIGAxkN&iuPr>gm3elS-XC6jP5<>D&v9H^=B=bAmE4x}2h#tj*1!Xa^5x9}Z&-cAfOO zhSJ~fOFv1abN1Dk|C)Vu5AW$RZ^rnReKW;VF`lwNNO3;Kd3!d&wS?c(ugSLLqzC)32yI?QaAMIgDr?nbKKC$oHpCyr+aMIsC*58k_ zY(cF7gAE0L+!tI