©2005 Felleisen, Proulx, et. al.

2.6  Problem (6.2.3)

Add fields to AUP that specify how far an instance moves to the left or right when the player hits an arrow key.

Also add fields to UFO that specify how far an instance can drop in one time slice of the game and how far it can move to the left or right during the same time.


class Examples {
  // an anti UFO platform placed in the center:
  AUP a = new AUP(100);

  // a UFO placed in the center, near the top of the world 
  UFO u = new UFO(new Posn(100,5));

  // A UFO placed in the center somewhat below u 
  UFO u2 = new UFO(new Posn(100,8));

  // A Shot right after being fired from a
  Shot s = new Shot(new Posn(110,490));

  // another Shot above s
  Shot s2 = new Shot(new Posn(110,485));

  // an empty list of shots
  AShots le = new MtShots();

  // a list of one shot
  AShots ls = new ConsShots(s,new MtShots());

  // a list of two shots one above another
  AShots ls2 = new ConsShots(s2,new ConsShots(s,new MtShots()));

  // a complete world, with an empty list of shots
  UFOWorld w = new UFOWorld(u,a,le);

  // a complete world with two shots
  UFOWorld w2 = new UFOWorld(u,a,ls2);
}

Figure: Some Sample Objects in the World of UFOs