From ae8729f2557c102e49546e964671ebd135450a33 Mon Sep 17 00:00:00 2001 From: Anndraj Date: Tue, 27 Feb 2024 19:33:38 +0330 Subject: [PATCH 1/9] Use The String Result For The Regex Then Check With Number THen Return It --- Base Structure/.idea/.name | 1 + Base Structure/.idea/vcs.xml | 6 ++++++ Base Structure/pom.xml | 6 ++++++ Base Structure/src/main/java/Warmup.java | 8 +++++++- Base Structure/src/test/java/StringTest.java | 2 +- Base Structure/target/classes/Advanced.class | Bin 746 -> 776 bytes Base Structure/target/classes/Warmup.class | Bin 707 -> 1385 bytes .../target/test-classes/StringTest.class | Bin 2047 -> 2298 bytes 8 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 Base Structure/.idea/.name create mode 100644 Base Structure/.idea/vcs.xml diff --git a/Base Structure/.idea/.name b/Base Structure/.idea/.name new file mode 100644 index 0000000..acd8f9b --- /dev/null +++ b/Base Structure/.idea/.name @@ -0,0 +1 @@ +Warmup.java \ No newline at end of file diff --git a/Base Structure/.idea/vcs.xml b/Base Structure/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Base Structure/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Base Structure/pom.xml b/Base Structure/pom.xml index 6803a74..4d38f33 100644 --- a/Base Structure/pom.xml +++ b/Base Structure/pom.xml @@ -33,6 +33,12 @@ junit-jupiter test + + org.jetbrains + annotations + RELEASE + compile + \ No newline at end of file diff --git a/Base Structure/src/main/java/Warmup.java b/Base Structure/src/main/java/Warmup.java index 2ae7eda..1a2120d 100644 --- a/Base Structure/src/main/java/Warmup.java +++ b/Base Structure/src/main/java/Warmup.java @@ -6,7 +6,13 @@ public class Warmup { * @return is the number th word of the sentence */ public String wordFinder(String sentence, int number) { - return null; + String[] redult = sentence.split(" "); + + if (number > 0 && number <= redult.length) { + return redult[number - 1]; + } else { + return " Number = " + number + " is out Of Bound"; + } } /** diff --git a/Base Structure/src/test/java/StringTest.java b/Base Structure/src/test/java/StringTest.java index 3e13bf7..95cc7d2 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 diff --git a/Base Structure/target/classes/Advanced.class b/Base Structure/target/classes/Advanced.class index 3235fe8a34a08917798d0d4e98969d6f762f4a09..c29e746eb3534546e35bfdadf17a527f5b160d54 100644 GIT binary patch delta 195 zcmYL?O%8%!3`Ae6lK8JEptymRiHR5S4(>e)doIGcJcaXBBW*Hmr+Mvr)@4KCPh-Ot zV-7r2r>bs4QWnxo9;{hPZ{IB|%_*E6``A0VIuGxlZX)+c(bwMIt6&>>i5S`P&sM=2 XC(ixL+iMd<`MWm~>4z!nxODjdA}9#N delta 171 zcmX|)%Mrpr3`5_VAu}8PkYowDz?~Udpa+`DJ&mLU3P>eX5qV*_NU~+geeqe2wY?%+ zb_62u6feXUMn_6vp&e{k39nz5JqJyGag=i3I7yjWD(c~Fw@1o}Mmu+#eri Uf4z&tFj<$@zbO-~b16g{skOj`=YA|O(6K#&%MDt@5_qck>>6j+o%f~&{OgAN_$H8ZamcK!@k zZrr-SjV3Jk0sbaqyff24vDGGhANSpR?z!jQ_UG^O3jnKFO(KG*hFA(c=w%o@;wQXd zbLX(IwSOcG#n8KAIhK0G5Y6Rx;)pXaJ&7dxG^A4K$H29ys&XyokfFzG*cL_4<|nhNYqg>@pA$$q~1DRTwykCl4q!k6b$`U#f|y~Zv-SYOfn2e(|mg(oRVx(8e%rm zMcBPOVfTB2yGE@nUEiPb?J*<{EZ0-JR2ai@m%vU`s%*N3C|ka~ zeW8Mje(f|8Yf>stxxBF$#PC)T@=Cr30q(0hLY|n z!>4w_Eyob_9d}Gyc+(Xr>&-^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B&~*wFs|Q#6D3_de8Iw z`~iQ+A9wMUDr1}P@;zRTyaaHJY6fPB>lMt=ji0ccPX+ROKu=?~v%JE;;RjtDDVQq% zp07vtMUVwzwMeXtK9Jc|ke~;$Lw#3lruYy1r!HP9h&mUMbrIki^=*knyWR&dl?rf1 IDF@K`2SKL0m;e9( From 6ed428b3b11d3bb804ff2b9df7a40250210e41fe Mon Sep 17 00:00:00 2001 From: Anndraj Date: Tue, 27 Feb 2024 19:50:26 +0330 Subject: [PATCH 2/9] Added The String Num For Gap And Count=0 Then For each Then The If Of Beeing Odd Or Even --- Base Structure/src/main/java/Warmup.java | 12 +++++++++++- Base Structure/target/classes/Warmup.class | Bin 1385 -> 1693 bytes 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Base Structure/src/main/java/Warmup.java b/Base Structure/src/main/java/Warmup.java index 1a2120d..a67c08e 100644 --- a/Base Structure/src/main/java/Warmup.java +++ b/Base Structure/src/main/java/Warmup.java @@ -22,7 +22,17 @@ public String wordFinder(String sentence, int number) { * @return if searchForEven is true ? return the number of even numbers : return the number of odd numbers */ public int oddEvenCounter(String number, boolean searchForEven) { - return -1; + String[] num = number.split(""); + int count = 0; + for (String i : num) { + int num1 = Integer.parseInt(i); + if (searchForEven && num1 % 2 == 0) { + count++; + } else if (!searchForEven && num1 % 2 != 0) { + count++; + } + } + return count; } /** diff --git a/Base Structure/target/classes/Warmup.class b/Base Structure/target/classes/Warmup.class index 2fc75ea9ed459aefa57861072aa0ec4c0555176b..e3fc658b50439b93f4fdb8111f25be08e6ab9d6a 100644 GIT binary patch delta 771 zcmYL`yKfUg5XQf~w@)_0z+og4NV#f(*UAKl?FQg0eTv0kOJYmb0mtLot^n+c7D4*%r`0X>)+2i0Is64VeZ~F za7+Lujw7SvL=rZJ1k%sEb+7co^XsLG->%hbfq>EUf>w=30c)cAU+}OUJoW4Ig^G^s z#<%aH5cb8?oa}dA3TU*gHj7iOnis4+S#AVN>os3MJYqv87lXiiC7`Y~I(|F+DPAAC zVsf%;I<6;?#zNSWcEydbBA1jUfn3;^a+;3Y0uEj0F>k0g8qYgTjAIxQsQ?A+2aR@w zrxJJaK`nlScuz-yLmQ>RHAxJB?gi z=^&3Y?5iV#2^1hx3m6c4(UVS6Gll7>Bbyu4nar+E9y$5}iF>lEOqW$#-ElS9)h*r9 z-omw2OP?(pw($v;o5*f4lWRPo&d`PtuTI{01?^>l|_0p#7Iz`=d0xiz%gUoEsPO`EjqOR_`=3x?DqcL%f?^nP^Yg^Na1gsPy*xK4y$khG=TN^>E zRQ?EiJ8Kc~%ot2%G54OibLKnuKKt%@uisBE09t6>c|FI)xXy_;QP!WLK9;@goODmm z4llX~SDkYK(bjEwGra7fi4_;C8H{30f5@KL(2q`{wgqCHcVc38^@wWtJ|x+IfS<=Vq?J&H zg9@EP5MKyg%+NE7*bq70XLs18d@vP*T_U?n>G$<7MUq_zY>dPls{A4_j|GF%&9r|! k095_~)cR{mEK*4Z)NOPFOYB?|3C}t Date: Wed, 28 Feb 2024 19:13:22 +0330 Subject: [PATCH 3/9] Get The Length Of Two Words Then Use toLowerCase For The All Letter Then compare To Off Them Then Return It --- Base Structure/src/main/java/Advanced.java | 1 + Base Structure/src/main/java/Warmup.java | 15 ++++++++++++++- Base Structure/target/classes/Advanced.class | Bin 776 -> 776 bytes Base Structure/target/classes/Warmup.class | Bin 1693 -> 2051 bytes 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Base Structure/src/main/java/Advanced.java b/Base Structure/src/main/java/Advanced.java index 4af5eae..fcc5aa9 100644 --- a/Base Structure/src/main/java/Advanced.java +++ b/Base Structure/src/main/java/Advanced.java @@ -10,6 +10,7 @@ public class Advanced { */ public String wordCensor(String sentence, String word, String newWord){ + return null; } diff --git a/Base Structure/src/main/java/Warmup.java b/Base Structure/src/main/java/Warmup.java index a67c08e..5ff581e 100644 --- a/Base Structure/src/main/java/Warmup.java +++ b/Base Structure/src/main/java/Warmup.java @@ -41,6 +41,19 @@ public int oddEvenCounter(String number, boolean searchForEven) { * @return The word that is first in alphabet column */ public String firstWord(String wordA, String wordB) { - return null; + int minLength = Math.min(wordA.length(), wordB.length()); + + for (int i = 0; i < minLength; i++) { + char char1 = Character.toLowerCase(wordA.charAt(i)); + char char2 = Character.toLowerCase(wordB.charAt(i)); + + if (char1 < char2) { + return wordA; + } else if (char1 > char2) { + return wordB; + } + } + + return minLength == wordA.length() ? wordA : wordB; } } diff --git a/Base Structure/target/classes/Advanced.class b/Base Structure/target/classes/Advanced.class index c29e746eb3534546e35bfdadf17a527f5b160d54..6514744c5664f18d32afc4dd51b5c1565cfe2b31 100644 GIT binary patch delta 25 gcmeBR>tNep&BVwz*@h{cQDX8GCSOLy$&Z-S08|nNj{pDw delta 25 gcmeBR>tNep&BVw%*@h{cQGD_gCSOK{$&Z-S08{Y>i~s-t diff --git a/Base Structure/target/classes/Warmup.class b/Base Structure/target/classes/Warmup.class index e3fc658b50439b93f4fdb8111f25be08e6ab9d6a..865bc7b0348ef51a9462e5fec3e49877ed17cdbc 100644 GIT binary patch delta 922 zcmYLIOHUI~7(KVW((hTftaUWrk$K8*Q>Zyoke9T&Tw8Y zm7kB*=5c{K>Yj1W>1=z_jkgWl!Cf8q0yu{I&JWKQG4FivrsQLRnA7Hsd38K>nq_ZG z3Lg3fNDvG@zSGXEJkg!uo?3z94Br7a)-Zsx?%p8IxwUU(N@Sc*GBl;CdWZu=YgH;b zj|*;R6c;f>E*&9U;yrmW!b(5HFNAblX3Z$ZT*R=JCt_7=twzWdWmh{Ud2LyQag*1k zc&-wshx_Bq)^V>37J2;46b4vy9p(VFoOR;(QEut{qK{q!clUoG$g8o-|M1zYY&F`bW6iw)d$yA0W4DcDE zLBq_c!~e6TgJ1nMOjE6iPV1AamJjBXz<|X15#{)d%%3$;ePw)(_e*j*Ej8Omp delta 587 zcmX|-%T7~K6o$Wb&S_6MwvCr4A=M))EmB)5;vFv(1tFT4bm)YTN@8N9<{%nJ415Bz z$NCKF&;f~w6MYEdV`!r2e>TWqueJ8N{Qtk!n}csF$+w+P+rUkhJ|tBOV~)Fz_T47j zR?upNYa7puqU`#M%&4rdu4Mfu3xjO_r=AvV&+)a;x74+ZBbzCgggPU%1?gC##zUdy`WA)LR5U5f zA!%#SQKh6xZ=buT>@IhY^Gtc}`&{tci4dkW8+jECqQ4xa6jO^yOmh6&H26b3PyM3u zQwK9HN|KHyqFMP+KCt(>)vEtbIO!#h?pF8Z1YF*e6L3XQp!!umd5!DxI)zp>y4=w( MQ54_R-iwU<1CPH)ga7~l From f9e6a28a999fd33003d6ce6671428c199cd6d68a Mon Sep 17 00:00:00 2001 From: Anndraj Date: Wed, 28 Feb 2024 19:58:27 +0330 Subject: [PATCH 4/9] Use The String Builder And The Regex Then Go in For Comparing Each Array In Words Then If TheY Are Equals Return The Sentence --- Base Structure/src/main/java/Advanced.java | 18 ++++++++++++++++-- Base Structure/target/classes/Advanced.class | Bin 776 -> 1322 bytes 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Base Structure/src/main/java/Advanced.java b/Base Structure/src/main/java/Advanced.java index fcc5aa9..5741092 100644 --- a/Base Structure/src/main/java/Advanced.java +++ b/Base Structure/src/main/java/Advanced.java @@ -10,8 +10,22 @@ public class Advanced { */ public String wordCensor(String sentence, String word, String newWord){ - - return null; + StringBuilder sb = new StringBuilder(); + String[] words = sentence.split(" "); + + for (int i = 0; i < words.length; i++) { + if (words[i].equals(word)) { + sb.append(newWord); + } else { + sb.append(words[i]); + } + + if (i < words.length - 1) { + sb.append(" "); + } + } + + return sb.toString(); } /** diff --git a/Base Structure/target/classes/Advanced.class b/Base Structure/target/classes/Advanced.class index 6514744c5664f18d32afc4dd51b5c1565cfe2b31..1a66578ed6cba5668459e4286094bfb506b0cde3 100644 GIT binary patch literal 1322 zcma)5T~8B16g|`3?v|wmT3T=ww0=R$R}mGFf)PplAQci(i1umPuCTc5*6kJ&pZycQ z^1`dWltdFAeDo)oh~C+@THQX_q%(K!+&Od3xjWy^KA!?uMqWb*k_tJBFcgM?J$}G* z7PohD8>Ky?>@g@yrfqun7^F;gOGSiX_)pQM=bHA;gSu%|3|E5+DS}=GmevqMpNjq{ z1`z)Xw|RsiT&r3p;g4qu|KjDd#b8b#4n~ngiZ~f>>)fg_q&g2b8RxUF1d-t=&OxVA zUacB-g<-n0v`HeL4P4WbLcXZD5XA^a86uw3CY{U#kK|QcqN0_`0k_Kr-6XF%6@#I_ zVA{rdeZOS5&w0tBOrqeFxwXYzQ>SXomE+-?$y1;h@ z(>9&DTQ(k=qG_>qUuJ|&xQvVRWW-MfiH1UBnpQcQ8O`B|6R=Mdgs2q$HXz{&#nEN~ zuHqW47_MWC#x%u0s6wT=_yy|A6Z9;~lL@VX=weu!S5k@|K0U&c9!@E9Qw=0OAg0UH z4Ge7`qfeLpyjb~#a^(oUx-5E`Zl4k6rbaR_1F h=fH3W3oW#Hngy#MTFyrsYVLNR2_2%7cm3NJe*rSz8L$8V delta 330 zcmZvXy$ZrG6opTcwqn%!Q?2!9(A7;4H^JFS@PRrBu9AlkoE*i$2k@c9bJL=N61ex| z{(Lz(+e2g@&)Xfq3ge?)xScvVt> Date: Wed, 28 Feb 2024 19:59:57 +0330 Subject: [PATCH 5/9] Use The String Builder And The Regex Then Go in For Comparing Each Array In Words Then If TheY Are Equals Return The Sentence --- Base Structure/src/main/java/Advanced.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Base Structure/src/main/java/Advanced.java b/Base Structure/src/main/java/Advanced.java index 5741092..51866ff 100644 --- a/Base Structure/src/main/java/Advanced.java +++ b/Base Structure/src/main/java/Advanced.java @@ -11,18 +11,17 @@ public class Advanced { */ public String wordCensor(String sentence, String word, String newWord){ StringBuilder sb = new StringBuilder(); - String[] words = sentence.split(" "); + String[] letter = sentence.split(" "); - for (int i = 0; i < words.length; i++) { - if (words[i].equals(word)) { + for (int i = 0; i < letter.length; i++) { + if (letter[i].equals(word)) sb.append(newWord); - } else { - sb.append(words[i]); - } + else + sb.append(letter[i]); - if (i < words.length - 1) { + if (i < letter.length - 1) sb.append(" "); - } + } return sb.toString(); From 2b11c9b07bdc71728d39d0b8220b951f1b4660a0 Mon Sep 17 00:00:00 2001 From: Anndraj Date: Wed, 28 Feb 2024 20:15:13 +0330 Subject: [PATCH 6/9] Lower The All Letter In The First Word Then Capitalize The First Letter And Doing This For The LastName Too --- Base Structure/src/main/java/Advanced.java | 9 ++++++++- Base Structure/target/classes/Advanced.class | Bin 1322 -> 2033 bytes 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Base Structure/src/main/java/Advanced.java b/Base Structure/src/main/java/Advanced.java index 51866ff..d109b32 100644 --- a/Base Structure/src/main/java/Advanced.java +++ b/Base Structure/src/main/java/Advanced.java @@ -34,7 +34,14 @@ public String wordCensor(String sentence, String word, String newWord){ * @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; + + String normalizedFirstName = firstName.substring(0, 1).toUpperCase() + firstName.substring(1).toLowerCase(); + + String normalizedLastName = lastName.substring(0, 1).toUpperCase() + lastName.substring(1).toLowerCase(); + + String fullName = normalizedFirstName + " " + normalizedLastName; + + return fullName; } /** diff --git a/Base Structure/target/classes/Advanced.class b/Base Structure/target/classes/Advanced.class index 1a66578ed6cba5668459e4286094bfb506b0cde3..ea7fbbf7d9215b30b7be80223fea126037d892ad 100644 GIT binary patch literal 2033 zcma)7-%}e^6#j0q$%e3j5+Jzthg5+E2t=#Jnnbijk<>u70b+~4Zj#%wW!a6p8<_g+ zAEB=uXZl)S(ixoTgOC16&R9KnH-XfoPMP8UID5{y-}jw!Z~lCK@(jR-_&$yh!YULE z5kwizJ>W+?YjW#;_EznIsCx|2f?*lnDnmFuzpEm~Fm>is@f^dtzt%F$hH&Cg5sqP) zflbGez=(=b4d*cSLf#;RA>uYogYsWVm;akDKfl*+lNrY~Okk2Qi62_rbQvalg9F6* z`MVOxl!n)!lPhmFh1FnK>U9l3=%6Ir&8gUBS+GNWM$ z%T%00ejtjrRp(yS@b+otdff6ztLp;<=;J>?l6(>j85Qr45;q!0+^P$bQz_aF!7y4j zEV0!(tO;kE*G#e`%XXccyWBD4zGGCpeS;vx%iRQd+8o8ipT2*o4o1M zR|MMuCaS9(+m>C8+MCi zF79&zH8()S0S!pfSL~Kk7wd*BSfX2#WhoKe)ivApsE2uTQ+WG!!yS#{%Q$YMqGDTi z*$%_ZnVN=mWFLrZa6^K|TjzDpb{;bP+zY7V7$n``R>KtTOxd;%TFrc)5`kYMg*5F5_)_apj*vw~F3e8n4nWOEaT6vhWn_H(G@7E{*at5XO5nYJmf; zVTE=K@8dd+GWc)uP-))#9qOH@7|JP&$#@%DE)rgePDb^}vqvcCk;&-QOdH8xkkFN- zHd58c7||8qE_c48(s+bnU6J9b>Q7Pj_@6&?rH$90Q2MYBX#sIsCoqH&jM3|UfyOkF z1Z0AKP*V5|Q@BO;9h~=JZxFNz+`tFO5gh{AAs|?6J}wZ4jL&H`IOCK_0qY$m1>!H6Okoxq zK9ekIRic$b(P83J@DYEGatHAW&9Wmx?Cjj2?AQFWQo+~LvqHXB)V0|3ac+^?pjw3R V1!dax$FFdgY;oG};TwDh{a-_>-W>n{ delta 430 zcmZXP%Su8~6o$Wjw#P$-PHZAHY6)ukNAJ4l{2>ORKPb*X~^1`W2l^ z6cmwGyVI;S>i6~5&1tQ9ttjREr%=lO(n`)rmNkti~|89BX79Vs+Zc)p8qGYXX&hP#LC5bKw From 8ac98d82558206c441cef30653a7e95329a2ac12 Mon Sep 17 00:00:00 2001 From: Anndraj Date: Wed, 28 Feb 2024 21:42:59 +0330 Subject: [PATCH 7/9] Definition something And Add Something And Then Compare To THe main word then if its not be same return it --- Base Structure/src/main/java/Advanced.java | 17 ++++++++++++++++- Base Structure/target/classes/Advanced.class | Bin 2033 -> 2346 bytes 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Base Structure/src/main/java/Advanced.java b/Base Structure/src/main/java/Advanced.java index d109b32..74c2033 100644 --- a/Base Structure/src/main/java/Advanced.java +++ b/Base Structure/src/main/java/Advanced.java @@ -50,7 +50,22 @@ public String normalizingName(String firstName, String lastName){ * @return if word contains Consecutive repeated letters, one of the repeated letters should be omitted */ public String doubleChar(String word) { - return null; + if (word == null || word.isEmpty()) { + return word; + } + + StringBuilder sb = new StringBuilder(); + char prevChar = '\0'; + + for (char currentChar : word.toCharArray()) { + if (currentChar != prevChar) { + sb.append(currentChar); + prevChar = currentChar; + } + } + + return sb.toString(); } + } diff --git a/Base Structure/target/classes/Advanced.class b/Base Structure/target/classes/Advanced.class index ea7fbbf7d9215b30b7be80223fea126037d892ad..8d458200e030a19f5f417b0bcc655718ff209811 100644 GIT binary patch delta 813 zcmX|9O-~b16g{tRW*$si6=cL3AtZ{n6htW$3#EV~VpYIzg!)yn3Ic^p(Zp3Z?p@5n zxH2&&Cay3hHPM8Xabf%qE_Lh9xB$-^37h-wz3<$6&$;jY-uRt6u4e4i#<+gbJ>|DO01Mm{m1Sw%Hq;Cqb%oZM$Kr)m4Hz76tp1bJXzIvl%a987m>g{sC{Pa)kf@ delta 546 zcmX|;J5N+m6otQiA9Lkq#4sTe3W*dL9UmiupuzBxk?~9h%jObidA(LWmAsJyV#D3fB{8!4I$SQi_HNB8B%9l z=Z0c6pD8TcK>o8(S$9(pN$BJbHyIWhYOQ%!jga{rHMz~aj2dIALfYi;7Plp;gGWM- zOWK6cCE_DG6Ox3xb|&pO)VXnwD~?(BUxalm*~KvWk=K*ab*H+dJ#daL&dXR?S}u79 zW6jxPMH%;7iZUK}MP2mCfm2lBB$KKlp+jlPJo96wTFgVr?jZyF=Hma?npQLD$xb(~ jkI4dWTK~lp518hua=WIUY1L~V-!iAORDF$iEYkfCg1SFc From 5270e0560baece40d5c97a8894c4217d7d8e9938 Mon Sep 17 00:00:00 2001 From: Anndraj Date: Sat, 2 Mar 2024 00:09:43 +0330 Subject: [PATCH 8/9] The Final --- Answers/40130212055.txt | 134 ++++++++++++++++++++++++++++++++++++++++ Answers/How To Send.txt | 3 - 2 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 Answers/40130212055.txt delete mode 100644 Answers/How To Send.txt diff --git a/Answers/40130212055.txt b/Answers/40130212055.txt new file mode 100644 index 0000000..2e14734 --- /dev/null +++ b/Answers/40130212055.txt @@ -0,0 +1,134 @@ +لطفا از پروژه خودتون یک کپی بگیرید +کپی را در این فولدر پیست کنید +نام پروژه‌ای که پیست کردید را به شماره دانشجویی خودتون تغییر بدید +40130212055 +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) { + String[] redult = sentence.split(" "); + + if (number > 0 && number <= redult.length) { + return redult[number - 1]; + } else { + return " Number = " + number + " is out Of Bound"; + } + } + + /** + * 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) { + String[] num = number.split(""); + int count = 0; + for (String i : num) { + int num1 = Integer.parseInt(i); + if (searchForEven && num1 % 2 == 0) { + count++; + } else if (!searchForEven && num1 % 2 != 0) { + count++; + } + } + return count; + } + + /** + * @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 minLength = Math.min(wordA.length(), wordB.length()); + + for (int i = 0; i < minLength; i++) { + char char1 = Character.toLowerCase(wordA.charAt(i)); + char char2 = Character.toLowerCase(wordB.charAt(i)); + + if (char1 < char2) { + return wordA; + } else if (char1 > char2) { + return wordB; + } + } + + return minLength == wordA.length() ? wordA : wordB; + } +} +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){ + StringBuilder sb = new StringBuilder(); + String[] letter = sentence.split(" "); + + for (int i = 0; i < letter.length; i++) { + if (letter[i].equals(word)) + sb.append(newWord); + else + sb.append(letter[i]); + + if (i < letter.length - 1) + sb.append(" "); + + } + + return sb.toString(); + } + + /** + * 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){ + + String normalizedFirstName = firstName.substring(0, 1).toUpperCase() + firstName.substring(1).toLowerCase(); + + String normalizedLastName = lastName.substring(0, 1).toUpperCase() + lastName.substring(1).toLowerCase(); + + String fullName = normalizedFirstName + " " + normalizedLastName; + + return fullName; + } + + /** + * 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) { + if (word == null || word.isEmpty()) { + return word; + } + + StringBuilder sb = new StringBuilder(); + char prevChar = '\0'; + + for (char currentChar : word.toCharArray()) { + if (currentChar != prevChar) { + sb.append(currentChar); + prevChar = currentChar; + } + } + + return sb.toString(); + } + +} + diff --git a/Answers/How To Send.txt b/Answers/How To Send.txt deleted file mode 100644 index 96b559e..0000000 --- a/Answers/How To Send.txt +++ /dev/null @@ -1,3 +0,0 @@ -لطفا از پروژه خودتون یک کپی بگیرید -کپی را در این فولدر پیست کنید -نام پروژه‌ای که پیست کردید را به شماره دانشجویی خودتون تغییر بدید \ No newline at end of file From 863c4355c60ec7daeb2c0519512de62e607ee612 Mon Sep 17 00:00:00 2001 From: Anndraj Date: Fri, 19 Apr 2024 22:14:35 +0330 Subject: [PATCH 9/9] hmm i just see i have a bug and now just debug it XD --- Base Structure/src/main/java/Advanced.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Base Structure/src/main/java/Advanced.java b/Base Structure/src/main/java/Advanced.java index 74c2033..4ec2b55 100644 --- a/Base Structure/src/main/java/Advanced.java +++ b/Base Structure/src/main/java/Advanced.java @@ -39,8 +39,15 @@ public String normalizingName(String firstName, String lastName){ String normalizedLastName = lastName.substring(0, 1).toUpperCase() + lastName.substring(1).toLowerCase(); - String fullName = normalizedFirstName + " " + normalizedLastName; + String fullName; + if(normalizedLastName.equals(" ")) + { + fullName = normalizedFirstName; + } + else { + fullName = normalizedFirstName + " " + normalizedLastName; + } return fullName; }