| Name: | Grader: | Score: |
Explain, briefly, the purpose java keyword extends.
None of the following functions are called directly from code you write. Explain when each function is called:
constructor
Step
React
v.SetSpeed(40); |
direction = speed = |
v.Turn(new GP.Attributes.Angle(45)); |
direction = speed = |
v.Turn(u.GetDirection().Difference(v.GetDirection())); |
direction = speed = |
v.Accelerate(u.GetSpeed() - v.GetSpeed()); |
direction = speed = |
shape.Move(v); |
position = orientation = |
shape.Turn(v.GetDirection()); |
position = orientation = |
shape.SetOrientation(v.GetDirection()); |
position = orientation = |
public class CoolLight { public CoolLight (double lightSize) { a int count = 0; b while (count < 3) { c MakeLight(count, lightSize); d count = count + 1; } } public void MakeLight (int number, double size) { e CoolShape light = ChooseShape(number); f light.SetPosition(new GP.Attributes.Coordinate(0, number * size)); g light.SetSize(new GP.Attributes.Dimension(size, size)); h light.SetStuff(); } public CoolShape ChooseShape (int number) { i CoolShape result; j if (number == 0) { k result = new CoolShape(); } l else if (number == 1) { m result = new CoolerShape(); } n else { o result = new CoolestShape(); } p return result; } }public class CoolShape extends GP.Shapes.Hexagon { public CoolShape () { q SetColor(new GP.Attributes.Colors.Red()); } public void SetStuff () { r SetFill(new GP.Attributes.Fills.None()); } }public class CoolerShape extends CoolShape { public CoolerShape () { s SetColor(new GP.Attributes.Colors.Yellow()); } public void SetStuff () { t SetOrientation(new GP.Attributes.Angle(45)); } }public class CoolestShape extends CoolShape { public CoolestShape () { u SetColor(new GP.Attributes.Colors.Green()); } public void SetStuff () { v Scale(1.05, 1.05); } }
public class Shrinker extends GP.Behaviors.Perpetual { GP.Shape myTarget; double percent; public Shrinker (GP.Shape target, double percent) { myTarget = target; } public void Step () { if (myTarget.GetSize().GetWidth() > 1) { myTarget.Scale(percent / 100.0, percent / 100.0); } } }When given a target that is a triangle and percent of 99.0, instead of shrinking the triangle incrementally one percent at a time, it makes the triangle disappear after only one call to Step. What is the error that causes the size to be reduced so drastically and how could you fix it? You may note your fixes on the code below rather than rewriting it from scratch under each question.
In the forest there is a cabin. All the doors and windows are sealed off and
everyone inside of the cabin is dead. How did all the people die?