Assertions
Category: Assertions
Author: Marty Stepp
Book Chapter: 5.5
Problem: Assertions
For each of the five points labeled by comments, identify each of the assertions in the table below as either being always true, never true, or sometimes true / sometimes false. public static int dice(Random rand) { int count = 0; int even = 0; <span class="assertionpoint">// Point A while (count < 10 && even < 3) { <span class="assertionpoint">// Point B count++; int roll = rand.nextInt(6) + 1; if (roll % 2 == 0) { <span class="assertionpoint">// Point C even++; <span class="assertionpoint">// Point D } } <span class="assertionpoint">// Point E return count; }
1) count < 10
2) even > 0
3) even < 3