Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding analyzer feedback to design.md for bird watcher concept exercise #2695

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions exercises/concept/bird-watcher/.meta/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,17 @@ This exercise's prerequisites Concepts are:
- `classes`: know how to work with fields.
- `booleans`: know what a `boolean` is.
- `basics`: know how to work with `integers` and how to assign and update variables.

## Analyzer

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

- `essential`: Verify that the solution does not hard-code the array passed in the constructor of the class `{2, 5, 0, 7, 4, 1 }`.
- `essential`: The solution requires that the user uses at least once a `For` loop, the method `getCountForFirstDays()` could be a great place to do it.
- `essential`: The solution requires that the user uses at least once a `For-Each` loop, the method `getBusyDays()` could be a great place to do it.
- `actionable`: If the student did not use `clone` in the constructor to make a copy of the array, instruct them to do so. This is because if not, allows code outside the class to mutate the contents of the array.

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

manumafe98 marked this conversation as resolved.
Show resolved Hide resolved
[analyzer]: https://github.com/exercism/java-analyzer
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ public BirdWatcher(int[] birdsPerDay) {
}

public int[] getLastWeek() {
return birdsPerDay.clone();
return new int[] { 0, 2, 5, 3, 7, 8, 4 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 interesting that the tests don't fail after this change. Makes me wonder whether the test suite is complete... But, I guess that is out of scope for this PR. Might be worth looking into in a separate issue.

Copy link

@phoenix-1729 phoenix-1729 Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should the test cases fail?(Can you please elaborate a little bit)
The array which getLastWeek() is returning is the same array which is being passed while creating the object of Birdwatcher.

`
private static final int DAY1 = 0;
private static final int DAY2 = 2;
private static final int DAY3 = 5;
private static final int DAY4 = 3;
private static final int DAY5 = 7;
private static final int DAY6 = 8;
private static final int TODAY = 4;
private BirdWatcher birdWatcher;

private int lastWeek[] = {DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY};
@BeforeEach
public void setUp() {
    birdWatcher = new BirdWatcher(lastWeek);
}
@Test
@Tag("task:1")
@DisplayName("The getLastWeek method correctly returns last week's counts")
public void itTestGetLastWeek() {
    assertThat(birdWatcher.getLastWeek())
        .containsExactly(DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY);
}

`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @phoenix-1729 I recommend to ask the questions in the issue itself

}

public int getToday() {
return birdsPerDay[birdsPerDay.length - 1];
}

public void incrementTodaysCount() {
birdsPerDay[birdsPerDay.length - 1] = birdsPerDay[birdsPerDay.length - 1] + 1;
birdsPerDay[birdsPerDay.length - 1]++;
}

public boolean hasDayWithoutBirds() {
Expand Down