0% found this document useful (0 votes)
62 views5 pages

Laporan Alice - 2 - 7 - Practice

Uploaded by

Wonk Brebes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views5 pages

Laporan Alice - 2 - 7 - Practice

Uploaded by

Wonk Brebes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

BAB 7

LATIHAN AKTIFITAS FUNGSI-FUNGSI

Java Fundamentals 2-7: Functions Practice Activities


Lesson Objectives:
• Use functions to control movement based on a return value

Vocabulary:
Identify the vocabulary word for each definition below.
Addition (+), subtraction (-), multiplication (*), and division (/).

Answer questions about an object, such as its height, width, depth, and even its distance
to another object.

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. Select an object and view its functions.

a. Select the White Rabbit object from the instance menu.


b. View the functions available for the White Rabbit object under the Functions tab.

2. Use a function to set a movement distance.

a. Make the white rabbit turn to face the bunny.


b. Turn the bunny to face the hedge

c. Use a getDistanceTo function to make the bunny move to the hedge.

d. Save the project.

3. Use a math operator to avoid a collision.

a. Use a math operator in the getDistanceTo function so that the baby bunny stops before colliding with the hedge.

b. Save the project.


4. Avoid a collision using depth.

a. Use the getDepth function to avoid a collision when the bunny moves towards the hedge. Adjust with additional math
calculations if necessary.

b. 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.

Optional Activities:
Complete the following optional practice activities below to continue practicing the concepts you learned in this lesson.

1. Create a new project using the desert template. Add a lioness object and three boulder objects to the scene.

a. Use functions to program the lioness to move precisely next to each boulder object; landing next to the boulders but
not going through them.

b. Save the project.

2. Create a new project using the grassy template. Add three trees and one bird to the scene. Position the bird in one of the
trees. Ensure that the trees are at least 10 meters apart from each other.

a. Use functions to program the bird to fly from one tree to the next, landing in the tree but not going through it. Hint:
Declare a procedure for the fly motion. Then, have the bird flap its wings while simultaneously moving the distance to
the tree.

b. Set the bird as the vehicle for the camera, so the camera follows the bird around as it flies around the scene. c.

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.

You might also like