| 6.170 | Laboratory in Software Engineering
Spring 2000 Amendments to Problem Set 4 Due: March 2, 2000 Handout 10 |
public void step(Dimension bound)
// modifies: this
// effects: Let p = location
//
v = (vx, vy) = velocity
//
r = the bounding rectangle of this
//
Set p_post = p + v
//
unless (1) part of r is outside bound
//
=> If adding v to p would move r horizontally farther away
//
from the center of bound,
//
set vx_post = -vx
//
If adding v to p would move r vertically farther away
//
from the center of bound,
//
set vy_post = -vy
//
Set p_post = p + v_post
//
or (2) r is within bound but adding v to p would bring
//
part of r outside bound
//
=> If r would move outside the horizontal range specified by bound,
//
set vx_post = -vx
//
And if r would move outside the vertical range specified by bound,
//
set vy_post = -vy
//
Set p_post = p
public abstract void draw(Graphics g);
// modifies: g
// effects: draws this onto g