Skip to content

Commit

Permalink
Merge pull request #18 from jetbrains-academy/stephen-hero-patch-2
Browse files Browse the repository at this point in the history
Update task.md
  • Loading branch information
nbirillo authored Oct 11, 2023
2 parents 3fba74b + cc84ea1 commit 03daebb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions duckShopServer/DuckShopServerDuckSetInitialization/task.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
In this task you need to implement a function
In this task, you need to implement a function
to be able to initialize a set of random ducks in the Duck Shop.

### Task

Implement `generateSetOfDucks` function from the `GameModeService` class in
Implement the `generateSetOfDucks` function from the `GameModeService` class in
the `org.jetbrains.kotlin.course.duck.shop.mode` package.
This function should generate a new set with `MAX_NUMBER_OF_DUCKS` random ducks.

You can find the already defined variable `MAX_NUMBER_OF_DUCKS`
in the `GameUtil.kt` file in the `org.jetbrains.kotlin.course.duck.shop.utils` package.

After implementing this task the `Set` button becomes alive:
After implementing this task, the `Set` button becomes alive:

![Current state](../../utils/src/main/resources/images/duck/shop/states/state_2.gif)

Expand All @@ -27,10 +27,10 @@ If you need to shuffle a list of elements, you can use the built-in function [`s

<div class="hint" title="How can I take N first elements from a list?">

To take first `N` elements from the list, you can use the [`take`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/take.html) built-in function.
Note, since `List` is an ordered structure, you always will get first `N` elements.
To complete the task you can take the necessary amount of shuffled elements and convert the result into a set.
Since the `Duck` enum has only different value, the resulting size of the set will be the same with the list size.
To get the first `N` elements of the list, you can use the built-in [`take`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/take.html) function.
Note, since `List` is an ordered structure, you will always get the first `N` elements.
To complete the task, you can take the necessary number of shuffled elements and convert the result into a set.
Since the `Duck` enum has only different values, the resulting size of the set will be the same as the list size.
</div>

<div class="hint" title="How can I convert a list to a set">
Expand Down

0 comments on commit 03daebb

Please sign in to comment.