Previous Slide


double, double, toil and ...

Next Slide

JAVA MAKES AN ANNOYING DISTINCTION BETWEEN INTEGERS AND REAL NUMBERS.

  • IN THE BOUNCING BALL APPLET, THE VARIABLE "gravity" WAS SET TO A FRACTIONAL VALUE IN "mouseDown":

    gravity = 0.2;
    (IF IT WERE LARGER THE BALL WOULD FALL TOO FAST.)

  • PREVIOUSLY, WE HAVE ONLY WORKED WITH INTEGERS AND ALL NUMERIC VARIABLES HAVE BEEN OF TYPE "int".

  • TO WORK WITH REAL NUMBERS, WE MUST DECLARE VARIABLES OF TYPE "double":

    double x, y, xspeed, yspeed, gravity;



The Web:
Technologies and
Techniques


Links to other course pages:


Williams College
Department of Computer Science
This page is part of a section of lecture slides related to " Animations " within the topic "Iteration and Animation in Java". Other slides within this section and other sections of slides for the topic "Iteration and Animation in Java" can be accessed using the links below.
  • Animation and Repetition
  • Animation and Tedium
  • Computer Animation
  • Tedium and Computer Speed
  • Non-Repetitive Repetition
  • Variable and History (again)
  • Animations
  • The "animate" Method
  • Conditionals in Animations
  • Animating Motion
  • Motion Animations and Conditionals
  • Modifying Multiple "Physical" Parameters
  • Modifying Multiple Parameters (cont.)
  • double, double, toil and ...
  • loops
  • Repetition without "animate"
  • Java "Do" Loops
  • Java "Do" Loops (cont.)
  • A Fitting Reprise