0% found this document useful (0 votes)
13 views2 pages

JF 2 9 Practice

The document outlines Java fundamentals focused on expressions, including creating and interpreting math operations. It provides practice activities involving coding a character's movement towards a castle wall and manipulating expressions to achieve desired outcomes. Optional activities are also suggested to further reinforce the concepts learned in the lesson.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

JF 2 9 Practice

The document outlines Java fundamentals focused on expressions, including creating and interpreting math operations. It provides practice activities involving coding a character's movement towards a castle wall and manipulating expressions to achieve desired outcomes. Optional activities are also suggested to further reinforce the concepts learned in the lesson.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Fundamentals

2-9: Expressions
Practice Activities

Lesson Objectives:
• Create an expression to perform a math operation
• Interpret a math expression

Vocabulary:
Identify the vocabulary word for each definition below.

Add (+), subtract (-), multiply (*) and divide (/).

A combination of values that, when arranged correctly, result in a final value.

Try It/Solve It:


Open the "WhiteRabbitProject" project you saved in the previous lesson. You will use this project for all of the practice activities listed
below.

1. Add a second castle wall on the right side of the screen.

2. Solve a distance problem with an expression.


a. Consider the following distance problem: The baby bunny moves towards the castle wall with a wand in his hand. He
moves to the center of the wall rather than in front of the wall.
b. Write an expression you could use to solve this problem.

3. Code an expression.
a. Program the baby bunny to turn to face the castle wall.
b. Program the baby bunny to move towards the castle wall. Use an expression so that the baby bunny stops in front of
the castle wall without coming too close to the wall.
c. Save the project.

4. Subtract depth from an expression.


a. Subtract the depth of the target object to make the baby bunny stop in front of the castle wall.
b. Test and debug, and adjust the expression as necessary.
c. Save the project.

5. Interpret an expression.
a. Interpret this expression:
this.whiteRabbit turnToFace this.wall
this.whiteRabbit move FORWARD this.whiteRabbit getDistanceTO this.wall + 2.0

b. Describe would happen if these lines of code were added to the WhiteRabbitProject. Would the WhiteRabbit stop
before the castle wall?

Copyright © 2022, Oracle and/or its affiliates. Oracle, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Optional Activities:
Complete the following optional practice activities below to continue practicing the concepts you learned in this lesson.
1. Browse the gallery tab “Gallery by Theme”. Set up an initial scene using the objects in the Outer Space theme. Set up an initial
scene with several boulder objects, an alien object, and a UFO object. Each object should be positioned several meters apart.

a. Declare a fly procedure for the alien and develop a flying motion.
b. Using an expression, program the alien to fly and land precisely next to a boulder.
c. Using an expression, program the UFO to fly and land precisely next to the alien.
d. Save the project.

Copyright © 2022, Oracle and/or its affiliates. Oracle, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. 2

You might also like