The quiz will cover:
Sample quiz questions (and answers):
import animator.*;
import java.awt.*;
public class Quiz1 extends Animated {
public void startup() {
Thing th = new Thing(55);
animator.include(th);
} // end of startup method
} // end of Quiz1 class
import animator.*;
import java.awt.*;
public class Thing extends Animated {
private int x;
public Thing(int xx) {
x = xx;
} // end of constructor
public void draw(Graphics g) {
g.setColor(Color.yellow);
g.fillOval(0,0,x,x);
} // end of draw method
} // end of Thing class
import animator.*;
import java.awt.*;
public class Quiz2 extends Animated {
public void startup() {
This th1 = new This();
That th2 = new That(th1);
animator.include(th1);
animator.include(th2);
} // end of startup method
} // end of Quiz2 class
import animator.*;
import java.awt.*;
public class This extends Animated {
private int here;
public void draw(int x, int y, Graphics g) {
g.setColor(Color.red);
g.fillOval(x-10,animator.getSceneHeight()-20,20,20);
here = x;
} // end of draw method
public int get() {
return here;
} // end of get method
} // end of This class
import animator.*;
import java.awt.*;
public class That extends Animated {
private This it;
public That(This is) {
it = is;
} // end of constructor
public void draw(Graphics g) {
g.setColor(Color.black);
int where = it.get();
int width = animator.getSceneWidth();
int height = animator.getSceneHeight();
if (where < width/2) {
g.fillOval(0,height-20,20,20);
}
else {
g.fillOval(width-20,height-20,20,20);
}
} // end of draw method
} // end of That class
Solutions: