In this lab, you will write custom reporter and predicate blocks to perform several useful calculations and computations.
-
Write a custom reporter block called min that determines which of two numbers is smaller and reports that value. If the two numbers are equal, report either one.
-
Write a custom reporter block called max that determines which of two numbers is larger and reports that value. If the two numbers are equal, report either one.
-
Write a custom predicate block called between that determines if a number is between two other numbers. If the first number is equal to either of the other two numbers or is between them, the block should report "true".
-
Write a custom predicate called at least as long as that determines whether a word has at least a specified number of letters.
-
Save your project as Lab3.4.
Write a custom reporter block called distance to that computes and reports the distance from a sprite's position to another point. Use the x position and y position blocks to determine the sprite's position. Remember that the formula for the distance between points (x1, y1)
and (x2, y2)
is sqrt((y2-y1)^2+(x2-x1)^2)
.
Criteria | Points |
---|---|
1.1 min | 0.5 |
1.2 max | 0.5 |
1.3 between | 0.5 |
1.4 at least as long as | 0.5 |
Bonus | 0.5 |
Total | 2.0 |