lab06 comment + simpler code

This commit is contained in:
SowinskiBraeden committed 2025-02-18 14:49:06 -08:00
1 parent ba260607a0
commit 85d402ae00
1 file changed
+13 -5
+13 -5
View File
@@ -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;
} }