From 954ec312e840a1000f716681ec3d9af56f582114 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 27 Oct 2020 13:56:40 +0700 Subject: [PATCH] Upload the completed verion of golfscore --- Week9/Assignment9/.classpath | 3 +- Week9/Assignment9/bin/CSVUtility.class | Bin 1180 -> 1464 bytes Week9/Assignment9/bin/CSVUtilityGiven.class | Bin 1755 -> 0 bytes Week9/Assignment9/bin/GolfScore.class | Bin 0 -> 6939 bytes Week9/Assignment9/class/CSVUtilityGiven.class | Bin 0 -> 1399 bytes .../class/Java101DrawingPanel.class | Bin 0 -> 1575 bytes .../Assignment9/class/Java101ImageUtil.class | Bin 0 -> 2277 bytes .../class/Java101ImageUtilExample.class | Bin 0 -> 2233 bytes Week9/Assignment9/class/Java101Viewer.class | Bin 0 -> 921 bytes Week9/Assignment9/course-db.csv | 4 + Week9/Assignment9/src/CSVUtility.java | 27 +- Week9/Assignment9/src/CSVUtilityGiven.class | Bin 0 -> 1399 bytes Week9/Assignment9/src/CSVUtilityGiven.java | 51 ---- Week9/Assignment9/src/GolfScore.java | 270 ++++++++++++++++++ 14 files changed, 295 insertions(+), 60 deletions(-) delete mode 100644 Week9/Assignment9/bin/CSVUtilityGiven.class create mode 100644 Week9/Assignment9/bin/GolfScore.class create mode 100644 Week9/Assignment9/class/CSVUtilityGiven.class create mode 100644 Week9/Assignment9/class/Java101DrawingPanel.class create mode 100644 Week9/Assignment9/class/Java101ImageUtil.class create mode 100644 Week9/Assignment9/class/Java101ImageUtilExample.class create mode 100644 Week9/Assignment9/class/Java101Viewer.class create mode 100644 Week9/Assignment9/course-db.csv create mode 100644 Week9/Assignment9/src/CSVUtilityGiven.class delete mode 100644 Week9/Assignment9/src/CSVUtilityGiven.java create mode 100644 Week9/Assignment9/src/GolfScore.java diff --git a/Week9/Assignment9/.classpath b/Week9/Assignment9/.classpath index 1cd9d95..70188ff 100644 --- a/Week9/Assignment9/.classpath +++ b/Week9/Assignment9/.classpath @@ -1,10 +1,11 @@ + - + diff --git a/Week9/Assignment9/bin/CSVUtility.class b/Week9/Assignment9/bin/CSVUtility.class index 102ee10c3a73fc2ca794afa5c82ae347b1206bad..956b3383ac32e5b4322b2f869ca15e8195ab6e04 100644 GIT binary patch delta 674 zcmZ9J&2JJ>6vfY*c{5X{6maO2Vml_rfQ1fVKSV7`zpRR;(G+!K8Z!#j8cIwcjXO5{ z1Io(8O;@apx@m|Dc5b@&Uog6LZHtGgD>IpU-^aQ4z4Ln?0=-f5=;Ui3z!L6#F+Ylq zrL;u0^G?Y>HX(31h!DafxFR526A4@kQW+M|8n0`+O%vBqG;l*8^vc`!ay761BDd)^ zUk0&^6#;e6dqeF^sgx=iSQ8k3^7fP6Ia0P`**C?p5oY zsLvbwo$pF3@B>`x0pP9F?@XFgM*!eq>1lrf43#$mxm z3=^1UPI5GhNfZ#rD$b(ByoD)Wy?A;8E@FnY5!^%yY5KRY#u^t2V+t8$TRf!5#yKuZ zT%y>5JVwkwR2auNZ(vTC2w)xyEQ)YnvdtM7fJk!8jA!W{7B{Ef!=M$Z7HP@JYhA=# zTbsA?hq&6eWe8@pbrRu2V!KXpmd?T` z;}%<}Z1@1TeHu2-`CK$My?{GJr}20EHQi^Gg#HI(WV9kq5D-E{2fU17AR&g}7*@rQ LsNmy(r`-Jumb_%$ delta 406 zcmXX?%SyvQ6g@K;n>GzvThpqz5JCGkK2vRcg3B(1ETp&!5=x|IQB!dv-S`D&>r!wf z=%y75et;j~ZwT(I-lj5e=gz(7#k|JvW6HNY}#gNU_&h0B(Z`xi%xBQmtHO%~I)b`z`Zk^el=d{eB#Igz<^9;gsuKl3L zI;;{@xDkBvi9nTZVqX}e1GvGRWOn*U)%(!ug&s0J%qFv4!G!)nl#l-*_87U?YV92O41u-(%0Vg34ieVBmbp~~uZq9}Qc^EK4 ZGhi_cksfXTLktnSo7Y<=cW z=$lWx>I<-BmF2U4#I@8nU#+>#Id^{h_m>j@6Rs1K@n(sX6~AqlId<{RyLm5mM;*#>$r|TEf7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8BUS!2jMdl)DkAhx!Lp_R!thMystqaADG+&8;NFL-=6*T(zL zkt&CZnx*9rf5J%K(sGv8M&@^~jWjTsxIY;46CiQ27@i1u2&R literal 0 HcmV?d00001 diff --git a/Week9/Assignment9/class/Java101DrawingPanel.class b/Week9/Assignment9/class/Java101DrawingPanel.class new file mode 100644 index 0000000000000000000000000000000000000000..0bb4bf1470854fda811013cfa0c7510bdafee68d GIT binary patch literal 1575 zcmaJ>-%}e^6#i~D$-=sY00LH%ibyp-DuJ{XAq^@)XpmnvRHibc-XynSo6T-!_lAnk z{Uh|%7oT-BnQ3Qu^QC`Mr&B$56Cs^;`mp!jbM~C?ob#P?@6#8L&j2jp(7*&{bbMeS zgxO(?<3k;D1|qm>knqtkK1On!Os^UE1oKLlRW1t#7Ln6&-M|QD)pA22e5&K7jwOar z#bUU!{eYkFEPp7oR+HC7cCCH?zVJk?q@+AU^p@pVa+N_(9vvN(Qr|L!i*8LYjBZcbdi zx9wHMhNUnkw1q^-OHxYZKd8W|-LO6|nB{hn7>{=Z>)Z3H_Ayl`6Z{S87ScO*C051w2RSpcFA* z$bC;xTc|H(>t|wRdVtvTiUMY1K_)gQ*z&0_MUz2u+tiE6UMnm&yYEq#%F+|OnK!V5 zT?!G6oqK=hA6sDmCHj*9@EK}+>yTOD&^Hf>&1}-Sf^Q;2x7k+fd;3g z;@J+R(9e3%OBFbF&ffn+!Z2JTzWM`leW2Pvl`oYp2FnWOHqh@?eBqr4FQ593c&rO~ zXLF6}Po}6vQDTuq9eb*qWrn#6rYz^gZHO#!LWT5d-r!Z~dZ#+>lIynXHrg!)v*b9! zE85)m1rhPfU_E_|-r(HkPR$nnT+cE8Dp>=XmmCjHTjDk5M+5eIl?S3K^Mf7eLln7f zmn|vsI*8S)uhjRt+~^5-vmIvWL7AZEh0#ZsiB^ryQ<$dp9g-YG5vF}5-37~>6*5}x zY&HD^p?mQ}qzmnDgh`5!)J3!d{Z9{n$Br1w-U9p3Zb(X3~EltZA%+ONSSjBa|;tC(C1u!6JLQ zzkUB-DfcM--O~#3%-L@!X{(7$JV&SHCm6X$$3#w>54Lb`i_CX1x)Qz|?jUwEq5{Sf zlaUU_9%=0NfB$(DqP44nhXx92P+2z7*u(8(It^_FW;|}cxCA^OVd_$-yl7~o6)0g=V%I||^ literal 0 HcmV?d00001 diff --git a/Week9/Assignment9/class/Java101ImageUtil.class b/Week9/Assignment9/class/Java101ImageUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..519982083697b86c00f07eafa8e57a0df5f3c0d1 GIT binary patch literal 2277 zcmZ`)>r)d~6#rfF*sv@Qg8`#}vA#l3f~cSbu!4fYK&(-0#6A|d35!WK-7JE&58GO2 z`Y-gOU!3VD+Yf=3X}|SL|0JiQJ!dyy?7-~Ix%ZxP&+B*2J^Rm_KmGzRjOQw%7*#N) zqJh`(0In$bFo3H8OsMc;k_Fe8TxT++;xwjJ+(1&nOe1b06~L^DIiyuO+){BKA2GSD zAfw<8Z||z;#5|LGOg?6kRd8QLHx}651KxeY>d6yac1E8H(rJz&V%Wm{&9Anzba|h(k4b zvZ&|fUE3)1a{?NA5feDX`;B;Iog$0Ru)^euX;wJ?c)ch`k|kH- zA~l;e+GcJ|M@~hilT#7LS%p|^Bwm+3)oQg&PHSU|?0lLliU=QPMDga|%oi zWqd)EbMy)9WcvEXk}TWgPJyMN0$ZSGQZJQEJ7P(FIbyHKNTpV*2*=y6U`@j#tZUf7 zV+~*8iH5K6gc^mx6=-pc>+5!W(kz%{^lN;>G11*``R-FD-?2jTOg+YY=c0y7xXimD zCc^?jw)PH6ixATAJsbN0F%8e~qd?zefxvY_HMks+M^3XuY%?M^4BHWuEi+Hb{fwvU zb+>Zw;hA1srM?u;uHPXDr(*G>zP$BjAfB zlPq%>lG5W#)0ULvN1^RRVU32@Au7%_nbX$_w$oFDwx#pyAa7-wW;~1}O^J%(Oh9k+ ze(yYv(QJ*e?95K00;NDroh^HX(kcjldbAeuvqFMw~@I?fL2xQuWY!c^eJc zO?Yl@!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LFV&vaMSKz>a zqW%nHKy6Tc(L{qP$0(Fe3Sm;Qi33ki892Cws-Rr;`8V*hx%%zSR|0mK2m2Q4*_ZiM zpfl2P%1X+57>vIXL#W~!NNjnH49T!Zlv6_otFz){JlIHFb16K}mDUHF9<1YI{G&xRtt-e<#2A@w&H zz8RmOsA&Udd~qeHgf?*87gvL-x`Ectpxhf&dV^|&osgUgDk%=SX4h3|bLa1Mh4RmJ znex}pANGRo!U6W%c{;}!ZkQoB1`5$jk`TZP z=#qGzqwP5q{um9f?@}}mxxGR+J&jFX6w|(u=Ee=Q?FLgDYwjgxUp01SJ%so*E2^@a$1}WiidD0?Zoxc18#0gAc>pe}p-4hJem8OGZiM82ybC);a3< z;wt$bq;(lrH8Bk%TWI(RjW?g5=_x`}(JeIlw$SqZo`XsngMSe;T=bGnBJ(0md;S9# Ci`hT` literal 0 HcmV?d00001 diff --git a/Week9/Assignment9/class/Java101Viewer.class b/Week9/Assignment9/class/Java101Viewer.class new file mode 100644 index 0000000000000000000000000000000000000000..d180da7711e76b05e7c191ea00f6cfd40193cf3e GIT binary patch literal 921 zcmZ`%%WhIZ82$#%Fa_yFDk!DU3%0_kh&5i4*0AX}^{=G)R~<*S}+JFV4hjlo#!HZ6wnvh7&gz0SVn z?#TT%-6ZwU^@CHYejVy))sqMBD)LZ+3Csx03d}Kts@sZu(OyI7$5aCqI7eKPY(I#yfN7sI%R48!QK zUbC&fde(i@=UR)5)B?%-asxx zV%V!}4DKq@A+xT|Ug(I`j9)gJ4CaOIwQlFI>sXGrnjO$7i2s+Er9T~{=K%OYvEl}; zVLFxQ85s1PH}9W-nWym84dVppCLXKmwbX z!dUtG|EV$f*iK- z7%w&D_>l555h}_JZDr}Kko*BoB-&GQ!0ms^qdfTq>9`T)+F+DFBI+thp`9ZC#M#&L zU&^gdyIs_|y(S57D8nkoutSb_=~dN8!X65=Uq>AiG%*F=IZ_A+j0oHmh%kXk2K>eX KiM*vTqkjPff5C?U literal 0 HcmV?d00001 diff --git a/Week9/Assignment9/course-db.csv b/Week9/Assignment9/course-db.csv new file mode 100644 index 0000000..bb9c489 --- /dev/null +++ b/Week9/Assignment9/course-db.csv @@ -0,0 +1,4 @@ +course-01,5,4,4,3,4,4,5,3,4,5,4,3,4,4,4,3,4,5 +course-02,4,4,3,4,5,3,5,4,4,4,5,3,5,4,4,3,4,4 +course-03,4,3,4,4,4,5,3,5,4,5,4,3,4,4,4,3,4,5 +course-04,4,3,4,5,4,5,3,4,4,4,5,4,3,4,5,3,4,4 diff --git a/Week9/Assignment9/src/CSVUtility.java b/Week9/Assignment9/src/CSVUtility.java index ca2eac0..8be41a7 100644 --- a/Week9/Assignment9/src/CSVUtility.java +++ b/Week9/Assignment9/src/CSVUtility.java @@ -6,9 +6,10 @@ import java.util.Arrays; import java.util.Scanner; public class CSVUtility { - + /** * reads all lines in given filename into an array of String + * * @param filename * @return array of String, each element in array is each line in file * @throws FileNotFoundException @@ -17,26 +18,36 @@ public class CSVUtility { // ENTER CODE HERE Scanner sc = new Scanner(new File(filename)); int length = 0; - for(length = 0;sc.hasNext();length++)sc.nextLine(); + for (length = 0; sc.hasNext(); length++) + sc.nextLine(); String[] filedata = new String[length]; sc = new Scanner(new File(filename)); - sc = new Scanner(new File(filename)).useDelimiter(","); - for(int i = 0;i<=length;i++)filedata[i]=sc.next(); + for (int i = 0; i < length; i++) + filedata[i] = sc.nextLine(); return filedata; } /** * read given CSV file into 2D array of String + * * @param filename CSV file - * @param header true if CSV file has a header line. The first line is header. The data start from second line. + * @param header true if CSV file has a header line. The first line is header. + * The data start from second line. * @return * @throws FileNotFoundException */ public static String[][] readCSV(String filename, boolean header) throws FileNotFoundException { // ENTER CODE HERE - return null; + String[] data = readFile(filename); + int lineOffset = header ? 1 : 0; + int maxElement = 0; + for (int i = lineOffset; i < data.length; i++) + maxElement = Math.max(data[i].split(",").length, maxElement); + String[][] csv = new String[data.length - lineOffset][maxElement]; + for (int i = lineOffset; i < data.length; i++) + csv[i - lineOffset] = data[i].split(","); + return csv; + } - - } diff --git a/Week9/Assignment9/src/CSVUtilityGiven.class b/Week9/Assignment9/src/CSVUtilityGiven.class new file mode 100644 index 0000000000000000000000000000000000000000..303e829a0a2cc592f15541c57fbf6c27d0c652aa GIT binary patch literal 1399 zcmZux&sQ5&6#gEW$xFw9kiY;bO)F}fA0(uf8Y;9%rKMs+ss`hsT@A@dr=~NUOu*JP z|AVJnH|#vR2^=})xc2XGI?_{o5gcS*#l9Lr6k1 zp(89X_{iS23k}=bDBN3rut0&#swlCKbKt35g1Nq-sYfEB~6^i1;*O-`WsA- z1(-X|Ibq^GC6Hcg_yN0%;R6#FaY;Z6+#gth#g`@0|C8{zR|U?Rm_&}K4TnUn^zvys z-9iSYP>{H6;zL{!h%Q#DUsGeZ_4JOr?Re~`>DYB8u0X1nqz~S1QQ|6P?BR%@C?IkM zQn+T~V^vTOHd!o!If4F~zts$!e0_bY7HlhGH%!dq6RNE^keNWH2Zj5Y2R&*TxQS0C z7ERp3ZSF~DmfhBreh>Zc1xC}oLNnC}?g$KQ_>FJ#LCtSEiV%Yq{W@ics_B-u99o}Y$h8BUS!2jMdl)DkAhx!Lp_R!thMystqaADG+&8;NFL-=6*T(zL zkt&CZnx*9rf5J%K(sGv8M&@^~jWjTsxIY;46CiQ27@i1u2&R literal 0 HcmV?d00001 diff --git a/Week9/Assignment9/src/CSVUtilityGiven.java b/Week9/Assignment9/src/CSVUtilityGiven.java deleted file mode 100644 index bea40be..0000000 --- a/Week9/Assignment9/src/CSVUtilityGiven.java +++ /dev/null @@ -1,51 +0,0 @@ -// -// Source code recreated from a .class file by SNLinter -// (powered by FernFlower decompiler) -// - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Scanner; - -public class CSVUtilityGiven { - public CSVUtilityGiven() { - } - - public static String[] readFile(String var0) throws FileNotFoundException { - Scanner var1 = new Scanner(new File(var0)); - ArrayList var2 = new ArrayList(); - - while(var1.hasNext()) { - var2.add(var1.nextLine()); - } - - var1.close(); - String[] var3 = new String[var2.size()]; - - for(int var4 = 0; var4 < var3.length; ++var4) { - var3[var4] = (String)var2.get(var4); - } - - return var3; - } - - public static String[][] readCSV(String var0, boolean var1) throws FileNotFoundException { - String[] var2 = readFile(var0); - int var3 = var1 ? 1 : 0; - String[][] var4 = new String[var2.length - var3][]; - int var5 = 0; - - for(int var6 = var3; var5 < var4.length; ++var6) { - var4[var5] = var2[var6].split(","); - ++var5; - } - - return var4; - } - - public static void main(String[] var0) throws FileNotFoundException { - ArrayUtility.show(readCSV("course-db.csv", false)); - ArrayUtility.show(readCSV("golf-score.csv", false)); - } -} diff --git a/Week9/Assignment9/src/GolfScore.java b/Week9/Assignment9/src/GolfScore.java new file mode 100644 index 0000000..adc75f5 --- /dev/null +++ b/Week9/Assignment9/src/GolfScore.java @@ -0,0 +1,270 @@ + +//package solution; +import java.io.File; +import java.io.FileNotFoundException; +import java.text.DecimalFormat; +import java.util.Arrays; +import java.util.Scanner; + +public class GolfScore { + public static void main(String[] args) { + + // uncomment each testXXX() method to test that the corresponding method works + // properly + // when finish uncomment run() + + // testGetGolfers(); + + // testGetScores(); + + // testGetCourseName(); + + // testGetCoursePar(); + + // testCalculateScore(); + + // testCalculateHandicap(); + + String filename = args.length == 0 ? "golf-score-1.csv" : args[0]; + run(filename); + } + + public static void run(String scoreFile) { + // 1. get golfer's names from golf-score-1.csv + String[] golfers = getGolfers(scoreFile); + + // 2. get golfer's scores from golf-score-1.csv + int[][] golfScoreList = getScores(scoreFile); + + // 3. get course name from golf-score-1.csv + String courseName = getCourseName(scoreFile); + + // 4. get course par from course-db.csv + int[] coursePar = getCoursePar("course-db.csv", courseName); + + // 5. calculate out, in, and total for each golfer + int[][] scores = calculateScore(golfScoreList); + + // 6. calculate handicap for each golfer + int[] hc = calculateHandicap(golfScoreList, coursePar); + + // 7. print the result: golfer's name, out, in, total, hc + printResult(golfers, scores, hc); + + } + + /** + * get golfers name from given CSV file using provided CSVUtility class golfer's + * name are the first elements in each sub array + * + * Each line of CSV file is in format: golfer's + * name,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13,h14,h15,h16,h17,h18 + * + * @param csvFilename csv file that contain golfers and their scores + * @return all golfer's names in array of String + */ + public static String[] getGolfers(String csvFilename) { + String[][] data; + try { + data = CSVUtility.readCSV(csvFilename, true); + String[] golfers = new String[data.length]; + for (int i = 0; i < data.length; i++) + golfers[i] = data[i][0]; + return golfers; + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + return new String[0]; + } + + /** + * get all score from CSV file + * + * @param csvFilename csv file that contains golfers and their scores + * @return 2D array of int that each element contains scores of each golfer + */ + public static int[][] getScores(String csvFilename) { + // ENTER CODE HERE + try { + String[][] data = CSVUtility.readCSV(csvFilename, true); + int[][] score = new int[data.length][data[0].length - 1]; + for (int i = 0; i < data.length; i++) + for (int j = 1; j < data[i].length; j++) + score[i][j - 1] = Integer.parseInt(data[i][j]); + return score; + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + return new int[0][0]; + } + + /** + * gets course name for csv file. Course name is the first line. + * + * @param csvFilename + * @return + */ + public static String getCourseName(String csvFilename) { + try { + return CSVUtility.readFile(csvFilename)[0]; + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + return null; + } + + /** + * gets course 18-hole par for given course name extracted from csv file + * + * @param csvFilename + * @param courseName + * @return + */ + public static int[] getCoursePar(String csvFilename, String courseName) { + // ENTER CODE HERE + String[][] data; + try { + data = CSVUtility.readCSV(csvFilename, false); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return new int[0]; + } + for (int i = 0; i < data.length; i++) { + if (courseName.equals(data[i][0])) { + int[] pars = new int[data[i].length - 1]; + for (int j = 1; j < data[i].length; j++) + pars[j - 1] = Integer.parseInt(data[i][j]); + return pars; + } + } + return new int[0]; + } + + /** + * calculate handicap using System-36 + * + * @param scores + * @param par + * @return handicap of all golfers + */ + public static int[] calculateHandicap(int[][] scores, int[] par) { + // ENTER CODE HERE + int hc[] = new int[scores.length]; + for (int i = 0; i < scores.length; i++) + for (int j = 0; j < scores[i].length; j++) + hc[i] += calculateHoleHandicap(par[j], scores[i][j]); + return hc; + + } + + /** + * calculate handicap for a hole from par and player's score + * + * @param par hole's par number (3, 4, or 5) + * @param score player's score + * + * @return calculated handicap, 0 if score - par is 0, 1 if score - par is equal + * to 1 and 2 otherwise + */ + public static int calculateHoleHandicap(int par, int score) { + // ENTER CODE HERE + if (score - par == 1) + return 1; + if (score - par >= 2) + return 2; + return 0; + } + + /** + * calculates: sum(hole1 to hole9) -> out sum(hole10 to hole18) -> in out + in + * -> total + * + * @param golfScoreList + * @return out, in, total for all players + */ + public static int[][] calculateScore(int[][] golfScoreList) { + // ENTER CODE HERE + int[][] playerScores = new int[golfScoreList.length][3]; + for (int i = 0; i < playerScores.length; i++) { + for (int j = 0; j < 9; j++) + playerScores[i][0] += golfScoreList[i][j]; + for (int j = 0; j < 9; j++) + playerScores[i][1] += golfScoreList[i][j + 9]; + playerScores[i][2] = playerScores[i][0] + playerScores[i][1]; + } + return playerScores; + } + + public static void printResult(String[] golfers, int[][] scores, int[] hc) { + System.out.println(" Name:\tOUT\tIN\tTOTAL\tHC"); + System.out.println("------------------------------------------"); + for (int i = 0; i < golfers.length; i++) { + int out = scores[i][0]; + int in = scores[i][1]; + int total = scores[i][2]; + System.out.format("%s:\t%d\t%d\t%d\t%d\n", golfers[i], out, in, total, hc[i]); + } + } + + // test methods + + private static void testGetGolfers() { + String[] golfers = getGolfers("golf-score-1.csv"); + System.out.println("Expected:"); + System.out.println("[Player01, Player02, Player03, Player04, Player05, " + + "Player06, Player07, Player08, Player09, Player10]"); + ArrayUtility.show(golfers); + } + + private static void testGetScores() { + int[][] scores = getScores("golf-score-1.csv"); + int[][] expected = { { 4, 4, 6, 3, 4, 5, 4, 6, 6, 6, 3, 5, 4, 6, 4, 4, 3, 6 }, + { 4, 5, 6, 4, 5, 4, 5, 4, 8, 9, 4, 5, 5, 6, 5, 4, 4, 5 }, + { 4, 5, 5, 4, 6, 5, 5, 5, 7, 6, 3, 6, 4, 6, 5, 5, 4, 5 }, + { 5, 6, 4, 3, 5, 4, 4, 4, 6, 5, 2, 7, 4, 7, 5, 7, 4, 6 }, + { 4, 3, 4, 4, 4, 5, 4, 4, 5, 5, 4, 5, 5, 5, 5, 4, 5, 4 }, + { 3, 4, 4, 3, 3, 4, 4, 4, 5, 5, 4, 5, 3, 5, 3, 4, 3, 6 }, + { 6, 4, 6, 4, 5, 5, 5, 3, 6, 4, 4, 5, 4, 5, 5, 5, 3, 4 }, + { 4, 6, 5, 3, 4, 6, 4, 3, 4, 4, 2, 5, 4, 5, 4, 4, 3, 4 }, + { 5, 5, 8, 4, 5, 4, 4, 3, 5, 5, 4, 5, 3, 6, 6, 5, 4, 5 }, + { 5, 4, 5, 3, 4, 4, 4, 2, 5, 5, 3, 6, 4, 5, 4, 6, 5, 5 } }; + ArrayUtility.show(scores); + System.out.println("Comparing with Expected:"); + for (int i = 0; i < expected.length; i++) { + System.out.print(Arrays.compare(expected[i], scores[i]) + " "); + } + System.out.println(); + System.out.println("0 0 0 0 0 0 0 0 0 0 - expected compare result"); + } + + private static void testGetCourseName() { + String courseName = getCourseName("golf-score-1.csv"); + System.out.println("Expected: course-02"); + System.out.println(courseName); + } + + private static void testGetCoursePar() { + int[] coursePar = getCoursePar("course-db.csv", "course-02"); + System.out.println("[4, 4, 3, 4, 5, 3, 5, 4, 4, 4, 5, 3, 5, 4, 4, 3, 4, 4] - expected"); + ArrayUtility.show(coursePar); + } + + private static void testCalculateScore() { + int[][] golfScoreList = getScores("golf-score-1.csv"); + int[][] scores = calculateScore(golfScoreList); + int[][] expected = { { 42, 41, 83 }, { 45, 47, 92 }, { 46, 44, 90 }, { 41, 47, 88 }, { 37, 42, 79 }, + { 34, 38, 72 }, { 44, 39, 83 }, { 39, 35, 74 }, { 43, 43, 86 }, { 36, 43, 79 } }; + ArrayUtility.show(expected); + System.out.println("---"); + ArrayUtility.show(scores); + } + + private static void testCalculateHandicap() { + int[][] scores = { { 4, 4, 6, 3, 4, 5, 4, 6, 6, 6, 3, 5, 4, 6, 4, 4, 3, 6 }, + { 4, 5, 6, 4, 5, 4, 5, 4, 8, 9, 4, 5, 5, 6, 5, 4, 4, 5 }, + { 4, 5, 5, 4, 6, 5, 5, 5, 7, 6, 3, 6, 4, 6, 5, 5, 4, 5 } }; + int[] par = { 4, 4, 3, 4, 5, 3, 5, 4, 4, 4, 5, 3, 5, 4, 4, 3, 4, 4 }; + System.out.println("[17, 15, 19] - expected"); + ArrayUtility.show(calculateHandicap(scores, par)); + } +}