Skip to content
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

Starting to reformat loops into a unified concept #2773

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Updating about.md to make break and continue be under the Loop contro…
…l statements section

Adding two tests for task 5 and 6
Updating design.md to remove out of scope and add new missing learning objective
  • Loading branch information
manumafe98 committed May 7, 2024
commit f31c25c00cd138496676953169c3564dbbb55c65
8 changes: 6 additions & 2 deletions concepts/loops/about.md
manumafe98 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ which outputs:
1
```

## Break
## Loop control statements

Loop control statements are special keywords used within loops to alter the normal execution flow.

### Break

The break statement acts as an "exit door" for a looping construct.
When encountered within the loop's body, `break` immediately terminates the loop's execution.
Expand All @@ -206,7 +210,7 @@ which outputs:
4
```

## Continue
### Continue

The continue statement in the other hand acts similar to a "skip button" in a looping construct.
manumafe98 marked this conversation as resolved.
Show resolved Hide resolved
When encountered within a loop's body, `continue` skips the remaining statements in the current iteration.
Expand Down
5 changes: 1 addition & 4 deletions exercises/concept/making-the-grade/.meta/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
- Know how to repeteadly execute code using a `for-each` loop.
- Know how to repeteadly execute code using a `while` loop.
- Know how to repeteadly execute code using a `do-while` loop.

## Out of scope

- Specific iteration over a `Map`
- Know the control flow statements `break` and `continue`.

## Concepts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@ void testThreeOddScores() {
).isEqualTo(3);
}

@Test
@Tag("task:5")
@DisplayName("None of the scores are odd")
void testNoneOfTheScoresAreOdd() {
assertThat(
MakingTheGrade.countOddScores(List.of(20, 40, 60, 80, 10))
).isEqualTo(0);
}

@Test
@Tag("task:5")
@DisplayName("All the scores are odd")
void testAllTheScoresAreOdd() {
assertThat(
MakingTheGrade.countOddScores(List.of(11, 33, 55, 77, 99))
).isEqualTo(5);
}

@Test
@Tag("task:6")
@DisplayName("Two students passed the exam before the first non-passing score")
Expand All @@ -145,4 +163,22 @@ void testTwoStudentsPassedTheExamBeforeTheNonPassingScore() {
MakingTheGrade.evaluateChallengingExam(List.of(45, 90, 15, 100, 70))
).isEqualTo(2);
}

@Test
@Tag("task:6")
@DisplayName("None of the students passed the exam")
void testNoneOfTheStudentsPassedTheExam() {
assertThat(
MakingTheGrade.evaluateChallengingExam(List.of(5, 10, 25, 2, 37))
).isEqualTo(0);
}

@Test
@Tag("task:6")
@DisplayName("All the students passed the exam")
void testAllTheStudentsPassedTheExam() {
assertThat(
MakingTheGrade.evaluateChallengingExam(List.of(90, 98, 75, 80, 100))
).isEqualTo(5);
}
}