lab06 comment + simpler code
This commit is contained in:
1 file changed
+13
-5
@@ -46,19 +46,27 @@ public class BaseballStats {
|
|||||||
while (lineScan.hasNext()) {
|
while (lineScan.hasNext()) {
|
||||||
String current = lineScan.next();
|
String current = lineScan.next();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Personally I don't think a switch statement
|
||||||
|
* is needed for this part of the lab.
|
||||||
|
*
|
||||||
|
* At this scale its an unnecessary optimization
|
||||||
|
* that wastes lines of code. A simple if else chain.
|
||||||
|
*
|
||||||
|
* or in my case, ternary operators will do just fine.
|
||||||
|
*/
|
||||||
switch (current) {
|
switch (current) {
|
||||||
case "h":
|
case "h":
|
||||||
hits += 1;
|
hits++;
|
||||||
break;
|
break;
|
||||||
case "o":
|
case "o":
|
||||||
outs += 1;
|
outs++;
|
||||||
break;
|
break;
|
||||||
case "s":
|
case "s":
|
||||||
sacs += 1;
|
sacs++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
walks += 1;
|
walks++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user