CS111 Lab 6 Programming Problems

BoomerangWorld

In BoomerangWorld, BoomerangThrowers throw boomerangs. Assume that the boomerangs have an inner angle of 120 degrees. We can specify the size of the boomerangs (ie the length of one side), the number of boomerangs to throw, and how far apart (the offset) the boomerangs should land. When we create a BoomerangThrower barb, she starts at a specific place with her pen down and facing the right. If we ask her to throw fewer than one boomerang, she does nothing. The first boomerang she throws drops at her feet with its top where she stands. Regardless of the number of boomerangs she throws, barb stands in her initial position facing her initial direction when she is finished. The following pictures illustrate the result from asking barb to throw different numbers of boomerangs.

barb.throwBoomerangs(50, 1, 30);
barb.throwBoomerangs(50, 2, 30);
barb.throwBoomerangs(50, 3, 30);
barb.throwBoomerangs(50, 4, 30);

Our task is to fill in the code for the throwBoomerangs method in the BoomerangThrower class. The following skeleton is provided for us.


public void throwBoomerangs (double size, int number, double offset) {

  System.out.println("throwBoomerangs("+size+", "+number+", "+offset+");");

  // add your code here

}

We may also want to define auxiliary methods in the BoomerangThrower class. We should not need to modify the BoomerangWorld class in order for our code to work. However, we may modify it during testing.