Programming Languages Chapter 16 This Introduce Javascript That Students Can See Another Language That

subject Type Homework Help
subject Pages 2
subject Words 533
subject Authors Barbara Ericson, Mark J. Guzdial

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Chapter 16
In this chapter we introduce JavaScript so that students can see another language that is similar to
Java, but not the same. We also use JavaScript to introduce some user interface concepts.
In section 16.1 we explain JavaScript syntax and how it differs from Java.
In section 16.2 we show how to put JavaScript in a Web page. This includes show how to
invoke a JavaScript function.
Students like the immediate feedback and the simplicity of JavaScript. But, it can be frustrating
if things aren’t working. There is no compiler to help you find mistakes.
Additional Items
We don’t cover recursion in the book but you can use the Turtle class to draw a tree like
structure (Figure 17). In the final version of the book classes (available from the publisher’s
Web site) there is a method drawTree that takes a branch length to start. The turtle that you call
the method on goes forward that branch length and then creates to two new turtles and turns each
slightly (-5) and (+5) from the current turtle’s heading. Then it tells each of these new turtles to
drawTree with a slightly smaller branch length. The method stops when the branch length gets
page-pf2
Another good introduction to recursion is a recursive subdivision of a triangle. Each triangle can
be broken into 4 smaller triangles and each of these can be broken into 4 smaller triangles, and so
on until the triangles get too small (Figure 18). This is in the final version of the Picture class as
a static method drawTriangles(smallestLength). In 3D graphics we do recursive subdivision of
What I like about these examples is that they are hard to do using iteration. You could also
recursively create web pages for directories with thumbnails of images in the directory. A
directory can have other directories in it so this is a nice tree structure.

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.