From 4b16ccf00e4f4cbb6e5d0158d16af6238428d7ae Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 20 Oct 2020 23:58:41 +0700 Subject: [PATCH] update .gitignore --- .gitignore | 4 + Week8/{EclipseIDE => }/Assignment8/.classpath | 0 Week8/{EclipseIDE => }/Assignment8/.project | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../Assignment8/bin/module-info.class | Bin .../Assignment8/bin/partA/IsReverse.class | Bin .../Assignment8/bin/partA/package-info.class | Bin .../Assignment8/bin/partB/Replace.class | Bin .../Assignment8/bin/partB/package-info.class | Bin .../Assignment8/bin/partC/CountNumbers.class | Bin .../Assignment8/bin/partC/package-info.class | Bin .../Assignment8/bin/partD/InsertArray.class | Bin .../Assignment8/bin/partD/package-info.class | Bin .../{EclipseIDE => }/Assignment8/numbers.txt | 0 .../Assignment8/src/module-info.java | 0 .../Assignment8/src/partA/IsReverse.java | 0 .../Assignment8/src/partA/package-info.java | 0 .../Assignment8/src/partB/Replace.java | 0 .../Assignment8/src/partB/package-info.java | 0 .../src/partC}/CountNumbers.java | 1 + .../Assignment8/src/partC/package-info.java | 0 .../Assignment8/src/partD/InsertArray.java | 0 .../Assignment8/src/partD/package-info.java | 0 Week8/JavaFiles/CountNumbers.class | Bin 1590 -> 0 bytes Week8/JavaFiles/InsertArray.class | Bin 1802 -> 0 bytes Week8/JavaFiles/InsertArray.java | 58 ---------- Week8/JavaFiles/IsReverse.class | Bin 1940 -> 0 bytes Week8/JavaFiles/IsReverse.java | 35 ------ Week8/JavaFiles/Replace.class | Bin 1645 -> 0 bytes Week8/JavaFiles/Replace.java | 55 ---------- Week8/JavaFiles/numbers.txt | 100 ------------------ Week8/readme.txt | 2 + 32 files changed, 7 insertions(+), 248 deletions(-) create mode 100644 .gitignore rename Week8/{EclipseIDE => }/Assignment8/.classpath (100%) rename Week8/{EclipseIDE => }/Assignment8/.project (100%) rename Week8/{EclipseIDE => }/Assignment8/.settings/org.eclipse.jdt.core.prefs (100%) rename Week8/{EclipseIDE => }/Assignment8/bin/module-info.class (100%) rename Week8/{EclipseIDE => }/Assignment8/bin/partA/IsReverse.class (100%) rename Week8/{EclipseIDE => }/Assignment8/bin/partA/package-info.class (100%) rename Week8/{EclipseIDE => }/Assignment8/bin/partB/Replace.class (100%) rename Week8/{EclipseIDE => }/Assignment8/bin/partB/package-info.class (100%) rename Week8/{EclipseIDE => }/Assignment8/bin/partC/CountNumbers.class (100%) rename Week8/{EclipseIDE => }/Assignment8/bin/partC/package-info.class (100%) rename Week8/{EclipseIDE => }/Assignment8/bin/partD/InsertArray.class (100%) rename Week8/{EclipseIDE => }/Assignment8/bin/partD/package-info.class (100%) rename Week8/{EclipseIDE => }/Assignment8/numbers.txt (100%) rename Week8/{EclipseIDE => }/Assignment8/src/module-info.java (100%) rename Week8/{EclipseIDE => }/Assignment8/src/partA/IsReverse.java (100%) rename Week8/{EclipseIDE => }/Assignment8/src/partA/package-info.java (100%) rename Week8/{EclipseIDE => }/Assignment8/src/partB/Replace.java (100%) rename Week8/{EclipseIDE => }/Assignment8/src/partB/package-info.java (100%) rename Week8/{JavaFiles => Assignment8/src/partC}/CountNumbers.java (99%) rename Week8/{EclipseIDE => }/Assignment8/src/partC/package-info.java (100%) rename Week8/{EclipseIDE => }/Assignment8/src/partD/InsertArray.java (100%) rename Week8/{EclipseIDE => }/Assignment8/src/partD/package-info.java (100%) delete mode 100644 Week8/JavaFiles/CountNumbers.class delete mode 100644 Week8/JavaFiles/InsertArray.class delete mode 100644 Week8/JavaFiles/InsertArray.java delete mode 100644 Week8/JavaFiles/IsReverse.class delete mode 100644 Week8/JavaFiles/IsReverse.java delete mode 100644 Week8/JavaFiles/Replace.class delete mode 100644 Week8/JavaFiles/Replace.java delete mode 100644 Week8/JavaFiles/numbers.txt create mode 100644 Week8/readme.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbce1db --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.metadata/** +**/.metadata/** +**/.sonarlint/** +.sonarlint/** \ No newline at end of file diff --git a/Week8/EclipseIDE/Assignment8/.classpath b/Week8/Assignment8/.classpath similarity index 100% rename from Week8/EclipseIDE/Assignment8/.classpath rename to Week8/Assignment8/.classpath diff --git a/Week8/EclipseIDE/Assignment8/.project b/Week8/Assignment8/.project similarity index 100% rename from Week8/EclipseIDE/Assignment8/.project rename to Week8/Assignment8/.project diff --git a/Week8/EclipseIDE/Assignment8/.settings/org.eclipse.jdt.core.prefs b/Week8/Assignment8/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Week8/EclipseIDE/Assignment8/.settings/org.eclipse.jdt.core.prefs rename to Week8/Assignment8/.settings/org.eclipse.jdt.core.prefs diff --git a/Week8/EclipseIDE/Assignment8/bin/module-info.class b/Week8/Assignment8/bin/module-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/module-info.class rename to Week8/Assignment8/bin/module-info.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partA/IsReverse.class b/Week8/Assignment8/bin/partA/IsReverse.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partA/IsReverse.class rename to Week8/Assignment8/bin/partA/IsReverse.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partA/package-info.class b/Week8/Assignment8/bin/partA/package-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partA/package-info.class rename to Week8/Assignment8/bin/partA/package-info.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partB/Replace.class b/Week8/Assignment8/bin/partB/Replace.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partB/Replace.class rename to Week8/Assignment8/bin/partB/Replace.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partB/package-info.class b/Week8/Assignment8/bin/partB/package-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partB/package-info.class rename to Week8/Assignment8/bin/partB/package-info.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partC/CountNumbers.class b/Week8/Assignment8/bin/partC/CountNumbers.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partC/CountNumbers.class rename to Week8/Assignment8/bin/partC/CountNumbers.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partC/package-info.class b/Week8/Assignment8/bin/partC/package-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partC/package-info.class rename to Week8/Assignment8/bin/partC/package-info.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partD/InsertArray.class b/Week8/Assignment8/bin/partD/InsertArray.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partD/InsertArray.class rename to Week8/Assignment8/bin/partD/InsertArray.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partD/package-info.class b/Week8/Assignment8/bin/partD/package-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partD/package-info.class rename to Week8/Assignment8/bin/partD/package-info.class diff --git a/Week8/EclipseIDE/Assignment8/numbers.txt b/Week8/Assignment8/numbers.txt similarity index 100% rename from Week8/EclipseIDE/Assignment8/numbers.txt rename to Week8/Assignment8/numbers.txt diff --git a/Week8/EclipseIDE/Assignment8/src/module-info.java b/Week8/Assignment8/src/module-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/module-info.java rename to Week8/Assignment8/src/module-info.java diff --git a/Week8/EclipseIDE/Assignment8/src/partA/IsReverse.java b/Week8/Assignment8/src/partA/IsReverse.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partA/IsReverse.java rename to Week8/Assignment8/src/partA/IsReverse.java diff --git a/Week8/EclipseIDE/Assignment8/src/partA/package-info.java b/Week8/Assignment8/src/partA/package-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partA/package-info.java rename to Week8/Assignment8/src/partA/package-info.java diff --git a/Week8/EclipseIDE/Assignment8/src/partB/Replace.java b/Week8/Assignment8/src/partB/Replace.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partB/Replace.java rename to Week8/Assignment8/src/partB/Replace.java diff --git a/Week8/EclipseIDE/Assignment8/src/partB/package-info.java b/Week8/Assignment8/src/partB/package-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partB/package-info.java rename to Week8/Assignment8/src/partB/package-info.java diff --git a/Week8/JavaFiles/CountNumbers.java b/Week8/Assignment8/src/partC/CountNumbers.java similarity index 99% rename from Week8/JavaFiles/CountNumbers.java rename to Week8/Assignment8/src/partC/CountNumbers.java index bed8594..326d38e 100644 --- a/Week8/JavaFiles/CountNumbers.java +++ b/Week8/Assignment8/src/partC/CountNumbers.java @@ -1,4 +1,5 @@ //This code is written by Siwat Sirichai +package partC; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; diff --git a/Week8/EclipseIDE/Assignment8/src/partC/package-info.java b/Week8/Assignment8/src/partC/package-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partC/package-info.java rename to Week8/Assignment8/src/partC/package-info.java diff --git a/Week8/EclipseIDE/Assignment8/src/partD/InsertArray.java b/Week8/Assignment8/src/partD/InsertArray.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partD/InsertArray.java rename to Week8/Assignment8/src/partD/InsertArray.java diff --git a/Week8/EclipseIDE/Assignment8/src/partD/package-info.java b/Week8/Assignment8/src/partD/package-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partD/package-info.java rename to Week8/Assignment8/src/partD/package-info.java diff --git a/Week8/JavaFiles/CountNumbers.class b/Week8/JavaFiles/CountNumbers.class deleted file mode 100644 index ae66ed525a0386e49a987174be12319a094d1d32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1590 zcmaJ>&r=*l6#kn1F)$3jnGgcR0TX4xWg`kI8;oWRW(_RSrAS3i!_vTnrDtoWmx4Q0 zsftGr#%s!|T)f0XNF^43fd7a$tGroOMf_%GQ`rdRVY+)>f3M&BzW2I+`{(&FfH{0) zq6IMnaSI6~1-kFKdv2!es;$iO`aN0F0?DhM^7N+yvGLTZfmVT@I;f_-a;8{vm6BBh zrhrv9dwyoYE6Y|`0`01{yDqE2l-}1S+RzzB=@PKV7hlII>Z+%u%%ko@&-O5+cR8P=AvJ#mSo6*9nq})R7joGyzcut&{emxB=xqx5p*SS z!^8rrV63p1&hAQNu;0S#axg1s*oHWCIu-dec=KWf@#r^!=S$C3~7% zljRM^m4k{r1KvzEx?|bqc4!=tbIawTr)9Pkw**ovEK*cO$KPbtwA|voavBZD8oJ7v zo|$t5n=~KZ$XwYC0vQ-62wXlT!CA}<+!na_|4?>%Bm+iyGg{d0Knx;$J2-yKzY)%Y zb7JBM;t3aQLXP1!jeG;pFgvDt*3u;Y(#K5ZwaW|MYu=qDs8&tZb3e;@vt;3(Bj)&+bJTX2DC4%NdCAa=s6 nlVM;6;{e!yu?8`GUU$5X9OqU>|AOCFSmd9{)e@HRH3t6$yflAB diff --git a/Week8/JavaFiles/InsertArray.class b/Week8/JavaFiles/InsertArray.class deleted file mode 100644 index 481717f33469cd14bcea094433e96a8283e1ec73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1802 zcmaJ>OK%%h6#lMf#xtHc#3XT>G){0*n%bTjC(f&>Q%XvpU`S&iD3av`89PIm;@FYn zP%4DjAhGO{6+*Bn%NC(Fsw#^$;t%i#Sg>V>D&U-Jhx$>ltT~T+zVp8K=f55`0c7!( zi2xKGY8V=V0+E~U$L?Ikt?tj|OEXBD( zT&vgJ+X5k%X}NYtyqPHGa`ew7cS3j$Lpma1Jdfe75Zkwp8r}hUt{qdL=%x(r*XG`? z`_;yFqwcu}YX(LIhNZ@@?#E?_xSNfeID@k~#=;oKIf0R9UEsFLK4ftmg^O4+!97yI>P*3SxzZq;tZ%WkE@ znftO;N7I~mB8((wt;;}_ssT%2%=wQWH{A&%jX9b|%MCS~(xUz*i#Y=sfkbbI?6~*I zAq|j2f10ru>_vO&vp6TVC@|Y&UFx!4wpZ*+E!$-Qr^mM3WxHx$wlni~CSzw7T98Wu z=^n^l7bIiL0G%ma?#FmN7+F9I*^0B)pV|ligW<|w5?Jm@ZNCe0T1_jr&Z=JShkn=v zZMWDyb@8+z*ZQG;7qk;%cZ^Cv-Kg!+J`QdARd4I~pybuxb4wM{3~o2v@<%t^Ln-UH zE)Xc@2yo!~Re>{!;Hha5vTrYdqeRdM*xV>qUW6RQEhTJ71bto)A=tnarf`v*+oFQ z;P;0e#h~L=;z9^Kfg=9I7_qeRZLjyqM5SXl)wG(skIk*v*BG}HN3ohG&{K+IHB-#p z#d<8&RQJBcI4KpWBQr+H(-{(Crx+#1*cdBzQ_a{ONzT20GfPuZoR0yMiW@+bzBBZc zr7(m=M6iw#eN=;VEzmD!t6o?u4DYm-xie4Uyhny)ZQ<$Zvd4tw6PpvQFJoa$` zHPYU~MSP9~zNB~b4vpk1Soj7uzNek}k+$Y1%;Ohi@GBPZ8;$D^EYYeii$Sc2b6BOZ J=a.length-1) { //If pos => a.length just put a before b - arraycopy(a, 0, result, 0, a.length); - arraycopy(b, 0, result, a.length, b.length); - } - else { - arraycopy(b, 0, result, pos, b.length); //put in b first - arraycopy(a, 0, result, 0, pos); //put the first part of a in (part before b) - arraycopy(a, pos, result, pos+b.length ,a.length-pos); //put the second part of a in (part after b) - } - return result; - } - - - public static void main(String[] args) { - // TODO Auto-generated method stub - int[] a = { 1, 2, 3, 4}; - int[] b = { 5, 6, 7}; - int[] c = { 8, 9, 10, 11, 12}; - - System.out.print("Printing array a: "); Replace.printArray(a); - System.out.print("Printing array b: "); Replace.printArray(b); - System.out.print("Printing array c: "); Replace.printArray(c); - - System.out.println("Now calling inserts!"); - System.out.println("------------------------"); - int[] d = insert(a,b,1); - int[] e = insert(a,b,4); //ERROR - int[] f = insert(b,a,0); - int[] g = insert(c,a,3); - int[] h = insert(c,a,-1); - int[] i = insert(c,a,7); //ERROR - - System.out.print("Printing array a, expecting {1,2,3,4} : "); Replace.printArray(a); - System.out.print("Printing array b, expecting {5,6,7} : "); Replace.printArray(b); - System.out.print("Printing array c, expecting {8,9,10,11,12} : "); Replace.printArray(c); - System.out.print("Printing array d, expecting {1,5,6,7,2,3,4} : "); Replace.printArray(d); - System.out.print("Printing array e, expecting {1,2,3,4,5,6,7} : "); Replace.printArray(e); - System.out.print("Printing array f, expecting {1,2,3,4,5,6,7}: "); Replace.printArray(f); - System.out.print("Printing array g, expecting {8,9,10,1,2,3,4,11,12} : "); Replace.printArray(g); - System.out.print("Printing array h, expecting {1,2,3,4,8,9,10,11,12} : "); Replace.printArray(h); - System.out.print("Printing array i, expecting {8,9,10,11,12,1,2,3,4} : "); Replace.printArray(i); - - } - -} diff --git a/Week8/JavaFiles/IsReverse.class b/Week8/JavaFiles/IsReverse.class deleted file mode 100644 index b918ab2dd8b6d80e7fa7b332447cddf50190849b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1940 zcmaJ?&2Jk;6#q^3W7e+Qn0%FOo78QSV0*VQ-xMb;w1&_?oGne&%FStQPtt9iU9-E6 z2xtBU1RM|u4qS2pBtTW=3lf#M@;7kfj)cU=+ub;c6{m-J^XAR(eaxFTZ+`ptQ5QfN zx6>Gc#35&(KxN22w72b2%XT+PR{f!9gbeC}<2vCr1}R^-n}&uIM>>NO$n@Zy&}o&f z`@X#s5L|rFv0KFO{MypmQsI6Ir!dTs&EOe~^i*OGt2;p`w#cy8AwT2Gv2VvK-SQnb zTn&9;Z_TGMhH;LG3{FQ5Q%k{Zu`T>S5byN(5ju;W!5N%oIK5?Wii+np?C_owJ|Hd# zZ8xNV#`E_JiI2p4NNzUB!6c?Q&S#Lr1%}Z9LC{&+QAjN}GIG>J;qC|+^btxW5h)^a zM3jiA5#bThpfku7uSu~FFFUSS>1@@7f5)!3NOE#Dv>TgMyB)7N<`{<7mPldCcF6BU zer=FrhV-h}@f%{%iHw}uPtRO*4$Afo&kKXlx7$?_KJc2su!>jGcona4T!}LFI>YqA zojdNfw<$`LdrD1`#6`Oidj1Z>XNOO|2TY9KwB2S)1k=l&x7lgWAC2>nq)+kAPFoCs zA3kYPh4Y6mZqG!;ZnajOP|RzXXPDhDhP-Xo3*{U$bK=7`Rj_F0LN8YrxzO(j4OjcH zb+b_@ABC<{1rzp-KCJyz>~)5jgBY5o7-TmIq0$ExX7hOH+kFuxrDX?!2sl`#4>du1y-MQP1>cFkmj6e|3Kxq%>KqiijXBdp9IN1 zp%67X#nr6(I9-!ut0pT}O`)NxR*iG3rfJr4vZ>J~2^88;3BYM+vQ_QZl=?JRvix|n zwX7;xWjTS6o=grDau9otjMK=fvQ<`CS!HGZJx&^whtWrP7Wfh8Xl-7O*B5(hBUxYS zt#w&fV#M^mMA79~GSicodxF`XKv#7hL!LX37_lJV6BxQ03ktE|pbi%40|G{=OvdQv z8^=9N;3KMuFDT@%pyL~y#SgUm3#RZp&f^dI5&oh-LBmCM2A7zDX|{k_D!LcqYkm}9&Ja!eOudM&1J#`H!^--_vCOmD{YT`ZG!nl!7h@ILha0m}=^KL7v# diff --git a/Week8/JavaFiles/IsReverse.java b/Week8/JavaFiles/IsReverse.java deleted file mode 100644 index 3cf02dc..0000000 --- a/Week8/JavaFiles/IsReverse.java +++ /dev/null @@ -1,35 +0,0 @@ -//This code is written by Siwat Sirichai -import java.util.Arrays; - -public class IsReverse { - - public static boolean isReverse(int[] a, int[] b) { - if (a==null&&b==null)return true; //Special Case #1: if a and b is null, result: true, return right away to prevent NullPointer exception. - if((a==null&&b!=null)||(a!=null&&b==null))return false; //Special Case #2: if only one of a or b is null, result: false, return right away to prevent NullPointer exception. - if (a.length != b.length)return false; //Special Case #3: if the length of a and b is not equal, result: false, return right away to prevent ArrayIndexoutofBound exception. - for(int i = 0;iYxd6g>~mc*bLgOcN3sVuuNk#C9B;1e}1AQV1=nbyIc6f_2rebH`(vCah}9^X|Rx+D@~=_Y;rNVN#W69>8#pq%wjdkX;|+DG=a1KSq+U=+Z?+yd zb+6G7o$a0+CulmpSHC+cH(HbVf5u5 zdTB|}D+<#`(DlRMz7E0Ce@C%9hp~|i&ZSFkws!b52iJq9zuDcZ`R$LqT7#8=t&Ug! zY{T1+a&6BGnhK-Y?Kjzne%NYt+jaj|AkC@BCPi^Aoio9Ij(jxGD~R*@F0%|*#Z}LL z1NDr7!gXF{8*E6(!(%MaJBYCvn9Tn`_|w?6O#a1VoXTg4<6pwaXVUJYn0oT}%ly-@ z^*XPkWa4a&i_;Va#<-q^i5sjYp~e4zQuglzB*fYg&lltosaMHkeGTIP1J7bB<3e_h zX@0zTfFY*Z&SNB57#cmm+m95fe~Hj+J`vu=GzS9%lzkEw2FW>uVSdy68x|NZP~jDv z?(0d4o{65GRov|9QNOW0&V%XN)^}Dlrnyy3cdL5bt;QJ}rdu@)w`xmb8{Dx?ZrKUV zUAI&H27+|{!Ulp(#&%q~dJWQ=keVfzr0#C~|JF@a(TqNCU#Q_$bUCVV9@Xq~WF$V% zxDdrtjOU_whVhsdB{@m-D49LL+^l9VJxA%|f@!bHI%n7$vW{t*8Lql%8xjb`B{s-f z=9E6|65~GYRmOeVWnt>mz9Wgy{%grk_?&=o8ZwOrefxxt{)%q;p4Rz^=J^@t@hdLi z6{hefW|Yns+W>NEgfFrTX4Mp5TtyVsB1&o%7u6=_)g8W>c5z8{Q0BvaFZ9j({{S2S BTwMSF diff --git a/Week8/JavaFiles/Replace.java b/Week8/JavaFiles/Replace.java deleted file mode 100644 index d7920a9..0000000 --- a/Week8/JavaFiles/Replace.java +++ /dev/null @@ -1,55 +0,0 @@ -//This code is written by Siwat Sirichai -public class Replace { - - public static int[] replace(int[] a, int v, int v2) { - if (a==null)return a; //If a is a null pointer, return immediately to prevent a NullPointerException - for(int i = 0; i < a.length;i++) //loop from 0 to the length of array a, number of completed iteration is stored in i (type int) - if(a[i]==v)a[i]=v2; //if the value of a at index i is equal to v, replace it with v2 - return a; //Return the replaced array a - - } - - public static void printArray(int[] a) { - if(a==null) { - System.out.println(); //Create a newline to make the format looks uniform - return; //If a is a null pointer, return immediately to prevent a NullPointerException - } - //NOTE: return; (a return statement without a return value) in a method with no return type will break out of the method. - for(int i = 0;i