Skip to content

Adding analyzer feedback for karls language concept exercise #2722

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
],
"prerequisites": [
"arrays",
"for-loops",
"strings"
],
"status": "active"
Expand Down
22 changes: 14 additions & 8 deletions exercises/concept/karls-languages/.docs/hints.md
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these hints may give away a bit too much. Based on the documentation I'd say they could be just a little bit more cryptic. For example, instead of

Try using the isEmpty() method.

it might say

One of the methods on the List type can be used to check if it is empty.

Same for the other hints.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@

## 1. Define a function to check if the language list is empty

- Try using the [`isEmpty()`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#isEmpty()) method.
- Try using the [`isEmpty()`][isempty] method.

## 2. Define a function to add a language to the list

- Try using the [`add(E element)`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#add(E)) method.
- Try using the [`add(E element)`][add] method.
- Reminder: methods that return `void` do not need any `return` statements.

## 3. Define a function to remove a language from the list

- Try using the [`remove(Object o)`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#remove(java.lang.Object)) method.
- Try using the [`remove(Object o)`][remove] method.
- Reminder: methods that return `void` do not need any `return` statements.

## 4. Define a function to return the first item in the list

- Try using the [`get(int index)`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#get(int)) method.
- Try using the [`get(int index)`][get] method.

## 5. Define a function to return how many languages are in the list

- Try using the [`size()`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#size()) method.
- Try using the [`size()`][size] method.

## 6. Define a function to determine if a language is in the list

- Try using the [`contains(Object o)`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#contains(java.lang.Object)) method.
- Try using the [`contains(Object o)`][contains] method.

## 7. Define a function to determine if the list is exciting

- Try using a [for-each loop](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html) through all of the elements, checking each one.
- Alternatively, try using the `containsLanguage` method from the previous step.
- Try using the `containsLanguage` method from the previous step.

[isempty]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#isEmpty()
[add]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#add(E)
[remove]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#remove(java.lang.Object)
[get]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#get(int)
[size]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#size()
[contains]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#contains(java.lang.Object)
15 changes: 14 additions & 1 deletion exercises/concept/karls-languages/.meta/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ This Concepts Exercise's Concepts are:

This Concept Exercise's prerequisites Concepts are:

- `for-loops`: know how to use a for-loop to iterate over a collection.
- `arrays`: know of the array collection type and that it has a fixed length.
- `strings`: data types used in this exercise

## Analyzer

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

- `essential`: If the student did not reuse the implementation of the `containsLanguage` method in the `isExciting` method, instruct them to do so.
Explain that reusing existing code instead of copy-pasting can help make code easier to maintain.
- `actionable`: If the solution did not use `contains` in the method `containsLanguage`, instruct the student to do so.
- `actionable`: If the solution did not use `isEmpty` in the method `isEmpty`, instruct the student to do so.

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 @@ -29,11 +29,6 @@ public boolean containsLanguage(String language) {
}

public boolean isExciting() {
for (String language : languages) {
if (language.equals("Java") || language.equals("Kotlin")) {
return true;
}
}
return false;
return containsLanguage("Java") || containsLanguage("Kotlin");
}
}