Skip to content

Commit b63d173

Browse files
Adding analyzer feedback for cars-assemble concept exercise (#2756)
* Adding analyzer feedback for cars-assemble concept exercise * Update exercises/concept/cars-assemble/.meta/design.md Co-authored-by: Sander Ploegsma <[email protected]> * Update exercises/concept/cars-assemble/.meta/design.md Co-authored-by: Sander Ploegsma <[email protected]> * Update exercises/concept/cars-assemble/.meta/design.md Co-authored-by: Sander Ploegsma <[email protected]> --------- Co-authored-by: Sander Ploegsma <[email protected]>
1 parent 4d0c00d commit b63d173

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

exercises/concept/cars-assemble/.meta/design.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@ This exercise's prerequisites Concepts are:
2525

2626
- `basics`: know how to define methods.
2727
- `booleans`: know how to use boolean operators.
28+
29+
## Analyzer
30+
31+
This exercise could benefit from the following rules in the [analyzer]:
32+
33+
- `actionable`: If the student did not reuse the implementation of the `productionRatePerHour` method in the `workingItemsPerMinute` method, instruct them to do so.
34+
- `informative`: If the solution is repeatedly hard-coding the value `221`, inform the student that they could store this value in a field to make the code easier to maintain.
35+
- `informative`: If the solution has `if/else-if` statements in the `productionRatePerHour` method, inform the student that creating a helper method to calculate the succes rate might make their code easier to understand.
36+
- `informative`: If the solution is using `if/else-if` logic that contains return statements, inform the students that the `else` keywords are redundant and that their code can become more clear by omitting them.
37+
38+
If the solution does not receive any of the above feedback, it must be exemplar.
39+
Leave a `celebratory` comment to celebrate the success!
40+
41+
[analyzer]: https://github.com/exercism/java-analyzer

exercises/concept/cars-assemble/.meta/src/reference/java/CarsAssemble.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ public class CarsAssemble {
44
private final int defaultProductionRate = 221;
55

66
public double productionRatePerHour(int speed) {
7-
return productionRatePerHourForSpeed(speed) * successRate(speed);
7+
return defaultProductionRate * speed * successRate(speed);
88
}
99

1010
public int workingItemsPerMinute(int speed) {
1111
return (int) (productionRatePerHour(speed) / 60);
1212
}
1313

14-
private int productionRatePerHourForSpeed(int speed) {
15-
return defaultProductionRate * speed;
16-
}
17-
1814
private double successRate(int speed) {
1915
if (speed == 10) {
2016
return 0.77;

0 commit comments

Comments
 (0)