Lab 7

Click HERE to view my Problem #1

Click HERE to view my Problem #2

Lab 7 Overview

In this lab, we used blocks for the first time. In Problem #1, we needed to create a block that used the distance formula, and then have a sprite use this block and state the distance between itself and a different sprite. In Problem #2, we needd to make a block that converted a number of feet into either miles or inches, depending on how large the number of feet was, and then have a sprite perform this task.

My Solution

For Problem #1, the distance formula, I first created a block called "distance". Within this block, I created 4 parameters. I then made this block perform the distance formula, using the 4 parameters. I then made two sprites. One of these sprites would move around the screen, and perfrom the "distance" block, using the x and y coordinates of both sprites as the parameters. For Problem #2, the feet to miles or inches converter, I began with a block containing two if statements. If the first parameter was bigger than a mile, then it would be converted from feet to miles. If the parameter was smaller than a mile, then it would be converted from feet to inches. I have a sprite ask for a certain number of feet, and then the answer is the parameter of the block I made. I then had the sprite say how many inches or miles the certain number of feet was.

Questions

1) Blocks are easy for repitition because you only need to make the code once, then plug the blocks in where you want them. They take less time to create and use over and over again.

2) Parameters are numbers or values that you can plug into blocks, and the code will use these.

3) The distance formula takes 4 parameters.

4) No parameters are needed when a block is telling a sprite to move 10 steps.

5) This program puts words in aplhabetical order. Blocks are named by the user, and are therefore easier to understand.

Click HERE to return to homepage.