Skip to content

Commit 832c703

Browse files
authored
Adding analyzer feedback for karls language concept exercise (#2722)
* Adding analyzer feedback for karls language concept exercise * Applying suggestions Update hints to not say exactly what to do Update isEmpty name to one that does not says directly what to apply change the analyzer topic that checks that the students re uses containsLanguage to informative Add an informative topic if the students uses an if statement on containsLanguage * Rollbacking rename of method isEmpty
1 parent 097c77b commit 832c703

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
],
8181
"prerequisites": [
8282
"arrays",
83-
"for-loops",
8483
"strings"
8584
],
8685
"status": "active"

exercises/concept/karls-languages/.docs/hints.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,32 @@
22

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

5-
- Try using the [`isEmpty()`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#isEmpty()) method.
5+
- One of the [methods][list] on the List type can be used to check if it is empty.
66

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

9-
- 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.
9+
- One of the [methods][list] on the List type can be used to add elements.
1010
- Reminder: methods that return `void` do not need any `return` statements.
1111

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

14-
- 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.
14+
- One of the [methods][list] on the List type can be used to remove elements.
1515
- Reminder: methods that return `void` do not need any `return` statements.
1616

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

19-
- 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.
19+
- One of the [methods][list] on the List type can be used to get elements on a certain index.
2020

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

23-
- Try using the [`size()`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#size()) method.
23+
- One of the [methods][list] on the List type can be used to get the size of the list.
2424

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

27-
- 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.
27+
- One of the [methods][list] on the List type can be used to check if an element is contained in the list.
2828

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

31-
- Try using a [for-each loop](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html) through all of the elements, checking each one.
32-
- Alternatively, try using the `containsLanguage` method from the previous step.
31+
- Try using a method already defined in the class.
32+
33+
[list]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html

exercises/concept/karls-languages/.meta/design.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ This Concepts Exercise's Concepts are:
4343

4444
This Concept Exercise's prerequisites Concepts are:
4545

46-
- `for-loops`: know how to use a for-loop to iterate over a collection.
4746
- `arrays`: know of the array collection type and that it has a fixed length.
4847
- `strings`: data types used in this exercise
48+
49+
## Analyzer
50+
51+
This exercise could benefit from the following rules in the [analyzer]:
52+
53+
- `actionable`: If the solution did not use `contains` in the method `containsLanguage`, instruct the student to do so.
54+
- `actionable`: If the solution did not use `isEmpty` in the method `isEmpty`, instruct the student to do so.
55+
- `informative`: If the student did not reuse the implementation of the `containsLanguage` method in the `isExciting` method, instruct them to do so.
56+
Explain that reusing existing code instead of copy-pasting can help make code easier to maintain.
57+
- `informative`: If the solution uses an `if statement` in the `containsLanguage` method, instruct the student to return directly the `contains` method.
58+
59+
If the solution does not receive any of the above feedback, it must be exemplar.
60+
Leave a `celebratory` comment to celebrate the success!
61+
62+
[analyzer]: https://github.com/exercism/java-analyzer

exercises/concept/karls-languages/.meta/src/reference/java/LanguageList.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ public boolean containsLanguage(String language) {
2929
}
3030

3131
public boolean isExciting() {
32-
for (String language : languages) {
33-
if (language.equals("Java") || language.equals("Kotlin")) {
34-
return true;
35-
}
36-
}
37-
return false;
32+
return containsLanguage("Java") || containsLanguage("Kotlin");
3833
}
3934
}

0 commit comments

Comments
 (0)