Here are the new tools you need for your While, Recursion, Graphics and Random quiz

Random - Random number generating object

import java.util.Random;
create a new Random Generator : Random myGen = new Random();
Ask your random generator for a new random number: int x = myGen.nextInt(5);
Get a random # starting at 0.

While:

While loop - repeats as long as a condition is met

statement to set up so that the first time through the loop it will run
while (test - if it is true, the code in the braces will run)
{
// do something, including changing some variable so the test will be false
}

do While - repeats, checking the condition after execution of the loop

Recursion - a method repeatedly calls itself until some stop condition - winds and unwinds

public static void method(int x)
{
    if (  condition to stop  ) handle bottom of the winding - where you will stop and turn around
    {
          // do something that does not call method again
    }
    else
    {
         // do something and call method passing it a different x
     }
}

To create:

Graphic - writing on Fang or PictureIts canvas -- will not ask you to write new code for graphic on test

Picture It

•import picture knowledge: javalib.worldimages.*;
•import color knowledge: java.awt.Color;
•Make WorldImages using AImage.make<shape> , AImage.makeFromFile
•Place images on top of each other using <your world image>. place (<your other world image> , x,y)
•x indicates how far to the right; y indicates how far down (positive)
•Show your image with <your world image>.show()

Fang

To set up fang:

import fang2.core.*;
import fang2.sprites.*;
import java.awt.*;
import java.awt.geom.*;

Your class must extend GameLoop ex: public class Wackadot extends GameLoop

Steps to add shapes to the panel:

Concepts:

Characters:

Equality Testing

Error Handling - Exceptions -- will not include on test

 

Existing Knowledge:

public class MyClassName
{
     // you can define a class variable here
     public static void main( )
     {

           // your statements will go here
           // your calls to method1 will have the form: method1()
     }
     public static void method1( )
     {

           // your statements will go here
     }
}


Loops

For loop - repeats when you know the number of times to repeat


for (statement to start the loop; condition that evaluates to true or false; statement to run when the loop repeats)
{
// do something
}

What you need to know:

FOR coding helps: (but not needed explicitly for the test)

Work with methods



If / if else / else

if (condition that evaluates to true or false)
{
// do something
}
else if (condition that evaluates to true or false) // remember that everything that met first criteria doesn't get here
{
// do something else
}
.
. // repeat else if as needed
.
else // remember to put no condition
{
// do something
}

If facts:

Here is the sheet you will have for your test