Quote:
Originally Posted by JasonMichael
Hey folks! I just finished Assignment 4 with the boomboom method. I could not figure out how to create a method called distance that randomly generated numbers in feet, instead of meters. Since it was only meters that I could get to work, I used randomization between 1 and 2 so the character would not go off screen during his jumps.
My question is, how do we set it to feet instead of meters, or can we randomize noninteger meters like randomize from .5 to 2.3 meters with the random numbers rounded off to the nearest tenth? Either one of these solutions would allow for a more varied jump distance while remaining on the screen.

First, there is no way I know of to change Alice to use feet automagically. The world, functions and methods are all predicated on the metric system.
Converting value given in feet to meters is however easy.
 Create a function called feet2meters that returns a number
 Add a numeric parameter called lenInFeet
 Add a variable called conversionFactor
 Set conversion factor to 0.3048
 return lenInFeet * conversionFactor
If you click the on the
more ... in the random number function you will find that you can set 3 values a minimum, a maximum, and integerOnly. The min and max can be set to any value as long as min<max and as long as the integerOnly is not set or false, the function will return values between min and max. Note that due to the way it works random number can return the min value but will never return the max value.
I am not sure why you want to round to 10ths, I usually do this for value I want to display as 3d text. To accomplish this write another function that takes in a number and returns the desired value. For tenths:
 multiply the given number by 10
 round the number using the round function. This drops the decimal part.
 divide by 10 to change to tenths.
As an exercise you could try and make this function return any number of decimal places. (hint: Add a parameter for the number of places and use the
a raised to the b power function