Skip to content
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
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
17 changes: 9 additions & 8 deletions exercises/concept/karls-languages/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@

## 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.
- One of the [methods][list] on the List type can be used to check if it is empty.

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

## 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.
- One of the [methods][list] on the List type can be used to get the size of the list.

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

## 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 a method already defined in the class.

[list]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html
16 changes: 15 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,20 @@ 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]:

- `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.
- `informative`: 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.
- `informative`: If the solution uses an `if statement` in the `containsLanguage` method, instruct the student to return directly the `contains` method.

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");
}
}