Skip to content

Commit

Permalink
Adding analyzer feedback for cars-assemble concept exercise (#2756)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
manumafe98 and sanderploegsma authored Apr 2, 2024
1 parent 4d0c00d commit b63d173
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 14 additions & 0 deletions exercises/concept/cars-assemble/.meta/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,17 @@ This exercise's prerequisites Concepts are:

- `basics`: know how to define methods.
- `booleans`: know how to use boolean operators.

## Analyzer

This exercise could benefit from the following rules in the [analyzer]:

- `actionable`: If the student did not reuse the implementation of the `productionRatePerHour` method in the `workingItemsPerMinute` method, instruct them to do so.
- `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.
- `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.
- `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.

If the solution does not receive any of the above feedback, it must be exemplar.
Leave a `celebratory` comment to celebrate the success!

[analyzer]: https://github.com/exercism/java-analyzer
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ public class CarsAssemble {
private final int defaultProductionRate = 221;

public double productionRatePerHour(int speed) {
return productionRatePerHourForSpeed(speed) * successRate(speed);
return defaultProductionRate * speed * successRate(speed);
}

public int workingItemsPerMinute(int speed) {
return (int) (productionRatePerHour(speed) / 60);
}

private int productionRatePerHourForSpeed(int speed) {
return defaultProductionRate * speed;
}

private double successRate(int speed) {
if (speed == 10) {
return 0.77;
Expand Down

0 comments on commit b63d173

Please sign in to comment.