Skip to content

Commit

Permalink
info1 lab2
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleinen committed Oct 16, 2023
1 parent 26b5a71 commit b5f1a98
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion hugo/content/classes/ws2023/info1/labs/exercise-02.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Use the project `chapter02/kara/kara-clock-lab02` for these exercises.
#### 1. Multi-Move

0. Open the project `chapter02/kara/kara-clock-lab02`. It contains several test worlds. Make sure you've instantiated the correct test world!
1. copy the multiMove method we discussed in class from `chapter02/kara/kara-loop-examples` to DigitDisplayKara. Test it in TestWorld0 and TestWorld1. TestWorld1 contains a setup you don't need to understand just now - just click "act" once and all Karas should be aligned in the middle like this:
1. copy the multiMove method we discussed in class from `chapter02/kara/kara-loop-examples` to DigitDisplayKara (the method definition is already there, you just need to fill it). Test it in TestWorld0 and TestWorld1. TestWorld1 contains a setup you don't need to understand just now - just click "act" once and all Karas should be aligned in the middle like this:

| Initial TestWorld1 | TestWorld1 after act() |
|:----------------------------------------------|:--------------------------------------------|
Expand All @@ -93,6 +93,18 @@ you're done test it in TestWorld2:

#### 2. Count Leaves

1. Open TestWorld4. complete the method `public int moveUpAndCount()` in `DigitDisplayKara`.
It should move up and count the leaves. It should stop either at the tree above or on the first free field. It returns the number of leaves counted.
Test your method by calling it from Kara's context menu.
2. When you're done, test your method in TestWorld5, which contains some edge cases like a full row and one with zero leaves.

| TestWorld5 before| TestWorld5 output | TestWorld5 after act() |
|:--|:----------------------------------------------|:--------------------------------------------|
| ![TestWorld5 before](./testworld5-before.jpg) | ![TestWorld5 output](./testworld5-output.jpg) | ![TestWorld5 after](./testworld5-after.jpg) |

#### 3. Preview
The next step would be a `public int countLeaves()` method that combines `public int moveUpAndCount()` and the `public void multiMove(int n)` methods: it counts the leaves and returns back to the home position. But we will do this next week!

## What to hand in

Hand in your lab report (pdf) and your code (zip) the night before the next lab, 10pm (22.00 Uhr). See [the Labs and Exercises page](../).
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b5f1a98

Please sign in to comment.