Category Archives: Alice

Math Expressions in Alice

Alice Supports many types of Math Operations.

 

For instance, let’s say that we have the variable someNumber  and it has a value of 2

alice-math_1

What if we want to multiply 2  by  0.5 ?

 

  1. click on the down arrow next to “2” and select “math”

alice-math_2

2) select “2*”  which means “2 times ”

alice-math_2

3) Select “Other” for the second number “b”

alice-math_3B

4) The calculator appears so you can  choose 5

 

5)  Select “5”

alice-math-calculator

6) Viola: You know have a math expression that represents 2 * 5

alice-math-4

 

8) Now let’s make a variable called “divisor” and then divide this expression by that

alice-math-5

9) Select the down arrow

alice-math-6

10) select as shown:

alice-math-7

 

11) Viola :

alice-math-8

 

 

 

Alice 2 : Asking User for Input

The world object has many, many useful functions including a way to ask the user for information—say  a number, a name or something.

  1.  Click on world
  2.  click on functions
  3. scroll down ot the ask user functions (See Diagram 1 ) and read below for more
Diagram 1

Diagram 1

 

Animated Gif showing the whole process of asking user for a number and then saying that number (using what as a String)

 

what-as-a-number-optiimized

Alice Unit 3-4 Assignments

FIRST: make sure you know:  how to use What as a String and perform Math expressions

Assign 1) Area of Triangle

Reference packets : #11, #12

Make sure you understand how to use “what as a String” 

Create a world that has a character (person/penguin/whatever) that will ask the user for the height of a triangle and the base of a triangle, and  calculate its area

  1. 3  different variables  : height , base  and  area  of the triangle
  2.  ask the user for  a number  for the height of the triangle and store it into  height (How to ask user for a number)
  3.  ask the user for  a number  for the base  of the triangle and store it into  base(ask user for a number)
  4.   use area formula and Alice Math expressions to compute the area.  (Note: if you don’t know how to use Math, refer to packet 11 or read this post  )
  5. Have your character say the area of the triangle  (remember  area  is a number. You must use what as a string to say it.

alice-area-triangle-take2


 

roman-translator-1-20

Assign 2) Roman Numeral Translator

Objective : to let the user type in a number between 1 and 10 and then have a character “translate” that into Roman Numerals ( I, II, III, IV, V, VI, VII, VIII, IX, X)

  • Ask the user for a number and store the return value into a variable called  numberToTranslate
  • use a series of “if/else tests to translate the number and say the appropriate Roman translation for each number between 1 and 10
  • Use “==” (link )  to test if two values are the same.screenshot61
  • if the user enters a number greater than 10 then  OR less than 1 , have your character say, use either a or b “Only enter numbers between 1 and 10”

either-or-roman-trans_1

Final result :

either-or-roman-trans_2

We are going to use the roman Numeral Translator file again, so it’s important that you don’t lose the file and give it a good name that you can easily recognize in the future.

Extra credit: Translate 1-20 (Note : You still need to display an error if they enter a number that is too big, which in this case would be >21)


 

mpg_v1_opt

Assignment 3 ) MPG:
 Create a world in which the

  •  Create 3 variables :  miles, gallons ,MPG   
    •  2 of the variables  store the return value of a function
      • The user is asked for the number of gallons  of fuel his or her car can hold. Use the return value of the ask use for a number function as shown below.screenshot21
      • Do the same thing for the the number of miles  that he or she can drive on a full tank. Use ask a user function to set the value of the miles variable.
  • a third variable called MPG .   This one will store the result of some math and will hold the car’s miles-per-gallon (MPG). Calculate the MPG with the following formulampg (2)

 

  • At the end , your character should say the value of the mpg  . (You must use what as a string )

Lastly,

  • use an if/else  as follows
    • if mpg is less  than 30, say “wow, what a gas guzzler”
    • else say “This car gets pretty good gas mileage”

 

temp-conver_opt1

Assignment  4) Fahrenheit to Centigrade : 

  • Create a variable called degreesFahrenheit   .
  • Store the return value of the ask user  function in  degreesFahrenheit  
  • Create a variable called  degreesCentigrade
  • Use the following formula to convert the degreesFahrenheit   to Centigrade using the following formula below:

     
  • use a character from thePeople collection to say the centigrade temperature.
  • Don’t forget that you can’t say numbers, you must use what as a string
  • use an if/else so that you say “Wow it’s cold” If the final temperature is less than 5 and “Whew it’s hot” if the temperature is greater than 30  (Centigrade)

 


Assignment 5) Circle’s Area and Circumference: Create a world with your choice of person from the Peoplecollection. When you play the world, it should

  • Ask the user for the radius of a circle. (This value should be stored in a variable ).
  • Use a circle shape to represent the circle.
  • The person should then say the area and the circumference of the circle.( Links for the circumference formula , area of a circle)
  • (For an extra point do the same thing with a “Sphere“. Ask the user for the radius and calculate the surface area and the volume.)  This should be done in the same file as the circle.

 


Assignment 5-extra credit ). Look up the formulas for the volume and surface area of a cylinder . Ask the user for the height of the cylinder and the radius, which should be stored in variables. Then calculate the surface area and volume of the cylinder . See if there is a cylinder shape in the gallery to use as a visual aid. And have an object say the volume and surface areas.

Methods , Variables, Functions Alice 2 Projects

 

#1  Apollo 15 :

screenshot.235

 

During the Apollo 15 mission to the moon, astronaut David Scott performed an experiment to prove that Galileo was right when he said that any two objects dropped at the same time would land on the ground at the same time in the absence of air. Scott, standing on the surface of the moon, dropped a hammer and a feather and indeed both objects hit the ground simultaneously.(Again, you must use “do together”)

Create an Alice world that recreates the experiment. You will find classes for the astronaut, lunar Lander, and the moon’s surface in the Web gallery’s Space collection. You can find a class for the Hammer in the Objects collection. Substitute any object of your choice for the feather.

Note : for following 3 steps, see Example 1 below

  1. Create a variable called  dropDistance
  2. set the value of this variable to the returned value of a distance function to make the objects fall the distance to the ground. (If stuck, read this )
  3. Make the two objects fall down the value of the distance

Example 1 (help with steps 2-4)

Steps 2-4 are similar to what is happening in the following picture :

screenshot.7

 


#2 Space Ship Repair :

spaceship-repair-demo-2

Create a space world with an astronaut and two spaceships(from the Web gallery’s Space collection). One of the spaceships is stranded with engine trouble, and the astronaut has arrived in the other spaceship to perform a repair.

  • The astronaut should initially be positioned just outside one of the spaceships, about to perform a space walk to the other ship. When the world is played, the astronaut should initially be positioned just outside one of the spaceships, about to perform a space walk to the other ship.
  • create a variable called walkingDistance ( to hold the distance that the astronaut must walk)
  • set the value of walkingDistance  to the returned value of a a proximity function  . (If stuck, read this ).  Here are some tips on using proximity functions in Alice 2.0.
    • NOTE: It turns out that, in this case, the best proximity function to use is distance to .
  • When the world is played, the astronaut should float to the stranded spaceship, appear to work for a few moments, and then float back to the rescue ship.
  • The repaired ship should then fly away, off the screen.

#3 Drag Racing:

spaceship-repair

 

  • Use  at least 1 set of comments
  • Create a world with a road (from the City collection) and two cars (from the Vehiclescollection).
  • Resize the road as necessary to match the size of the cars. The cars should be lined up side by side at one end of the road, which is a drag strip.
  • When the world is played, the cars should simultaneously move to the other end of the road and stop(You must use “do together”).
  • Change the duration of the method call that you use to move one of the cars so it is faster than the others.
  • Position the camera so you can see the cars as they approach the end of the drag strip.
  • Put an object at the end of the race to signify the ‘finish line’ and use a proximity function to move the cars to the end.

drag-racing-2


#4  Open Ended Project

  • Two or more objects
  • Must tell some kind of story
  • use at least 1 variable
  • use at least 1 function

bolivar_open_proj_penguin_ball cwong_open_proj_tag

Final Alice Assignment

This is your “cumulative Assignment”

  • It must tell a story
  • Minimum of 5 objects

 

Programming Requirements

  • Some kind of interactive event (#27) . Something should happen when a mouse is pressed, key is pressed etc

 

10 points of the following

 

  • Loop    (2 points )
  • variable (1 point)
  •  function (1 point)
  • custom object (save to file etc)  2 points

Alice Unit 5

5.1: Exercise Competition:

excercise_competition_emo

Three girls Jenny, Kelly, and Barb are enrolled in an exercise class. One day after class the three decide to have a friendly competition to see how many sets of 10 repetitions of running in place each can do before getting tired. Barb decides to go first and gets tired at 10 repetitions. Kelly goes next and she gets tired at 20 repetitions. Jenny, who has been in the exercise class for the longest, goes next. She gets tired at 30 repetitions.

Create a world that suites the competition.

  • Note: Basically, you are just using a parameter to determine how many times the girl “runsInPlace”
  • Important: Each of the girls should be an instance of ExerciseGirl class that you created in chapter 5.

 

excercise compe


 

EACH Assignment below requires the use of a parameter in some way.  If you do not have a parameter, as described, you will lose a lot of credit.

 

Here is a helpful link on how to create and use parameters, in case you forget.

 


5.2 : Jumping Jacks

jumping-jacks-optimized

Add a jumpingJack method to the ExerciseGirl class. The method should make the object perform jumping jacks .

  • Important: this method should have a parameter for the number of repetitions to perform.

5.3 : Marcello The Magician:

 

Marcello the magician has finally mastered his disappearing act. To perform the act, he places several items on a table in front of him. He stands with his right arm extended over an item. He says the magic word “Alakazam, Alakazee” and the object disappears. He repeats this procedure for each object on the table. Create a world in which Marcello (an instance of the Magician class from the People Collection) demonstrates his new act . In the magician object

  • you should create two new class-level methods:
    • sayMagicWords
      • should cause Marcello to say the magic words.
    • makeDisappear
      • This method should have an object as its parameter
      • should cause Marcello to turn to face the object, say the magic words (by calling the sayMagicWords method) and then make the object disappear by setting its opacity to zero (note: for some reason the bunny object cannot be made to disappear this way!).
  • gigantaicize
    • This method should have an object as its parameter
    • the object should be made to 5 times its original size!
  • Want to get an “A+”: then create a transmute method tha
    • takes an object  parameter
    • Changes a locust to a boar (hide the one , make the other appear)
    • changes a bird to a locust

Alice Unit 2

Unit 2 Quiz (mid -november-ish)

  • Review sheet with answers posted in Google Drive
  • converting other bases to decimals (unit 1)
  • methods vs functions
    • definitions
    • meaning of ‘return a value’
    • screenshots from Alice with connection to these definitions
  • variables
    • definition
    • types of variables
      • number
      • boolean
      • string
    • use of strings
  • identify where the ‘local variable’ button is in Alice

return-value-to-variable-alice-2

 


Drag Racing:

  1.  ( DO NOT SUBMIT THIS VIA Google classroom.   Show me this in class)
  2. Use at least 1  comment  Link
  3. Create a world with a road (from the City collection) and two cars (from the Vehicles collection).
  4. Resize the road as necessary to match the size of the cars. The cars should be lined up side by side at one end of the road, which is a drag strip.
  5. Put an object at the end of the race to signify the ‘finish line’
  6. When the world is played, the cars should simultaneously move to the other end of the road and stop (You must use “do together”).
  7. use the “move” method for both carsmove-method
  8. Change the duration  of the move method (see pic below) so that one car arrives before the other).
    alice-duration-website
  9. Position the camera  so you can see the cars as they approach the end of the drag strip.
  10.  use a function to figure out how far they should move (You want to replace the value “5 meters” with a distance function)

Then modify it

  1. create a variable called  driveDistance  and set its value to 1
    1. set the value of driveDistance   to the returned value of a the distance in front of  function
      unit-2-drag-race-variable-drivedisatnce-highlight
  2.  the car should move forward   driveDistance   meters

Space Ship Repair

spaceship_repair

Create a space world with an astronaut and two spaceships(from the Web gallery’s Space collection). One of the spaceships is stranded with engine trouble, and the astronaut has arrived in the other spaceship to perform a repair.

  1. The astronaut should initially be positioned just outside one of the spaceships, about to perform a space walk to the other ship. When the world is played, the astronaut should initially be positioned just outside one of the spaceships, about to perform a space walk to the other ship.
  2. create a variable called walkingDistance (to represent how far the astronaut must walk)
  3. set the value of walkingDistance  to the returned value of  a proximity function.screenshot.44
  4. When the world is played, the astronaut should float to the stranded spaceship, appear to work for a few moments, and then float back to the rescue ship. Hint : to get the spaceship guy to move in the right way (towards the ship). Use the “turn to face” method turn-to-face
  5. The repaired ship should then fly away, off the screen.

Before submitting check out some examples of code that prior students used and that did not get full credit here .

 


Apollo 15

apollo-15-animated_gif_louis

  • During the Apollo 15 mission to the moon, astronaut David Scott performed an experiment to prove that Galileo was right when he said that any two objects dropped at the same time would land on the ground at the same time in the absence of air. Scott, standing on the surface of the moon, dropped a hammer and a feather and indeed both objects hit the ground simultaneously.(Again, you must use “do together”)
    1. Create an Alice world that recreates the experiment. You will find classes for the astronaut, lunar Lander, and the moon’s surface in the Web gallery’s Space collection. You can find a class for the Hammer in the Objects collection. Substitute any object of your choice for the feather.
    2. Create a variable called  dropDistance
    3. set the value of this variable to the returned value of a distance function to make the objects fall the distance above the ground. Use screenshot.1289
    4. Make the two objects fall down the value of the dropDistance

 

 

B Before handing it in, look at some examples of work that students did and that did not receive full credit,. here.


 

End of Unit Open assignment

  • Tell a short story that
  • at least 3 objects
  • at least 2  variables
  • at least 2 functions
    • sets the value of a variable to a returned value of a function
  • uses that variable to move one of the objects
    • ie make sure that your variable is actually used to do something.

Below is just one example. Your story can be about any topic.

end-of-unit2-alice


Old assignments (ignore)

Penguin on a Table: Create a world with a penguin and a table. The penguin should be facing the table, standing next to it. The penguin should simultaneously flap its wings (use the wing_flap method) and move up in the air a distance that is exactly 1 meter higher than the height of the table. You can call the table’s height function to get its height. The penguin should then move forward to approximately the center of the table, and then move down to the surface of the table

 

What as a String