Documente Academic
Documente Profesional
Documente Cultură
2007 The College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents).
I think it is. From what I remember, the loc variable is required to actually retain the actual location as a finite variable whereas the getLocation() retrieves it objectively. 8. Why do you think the flowers that are dropped by a bug have the same color as the bug? Its easier to distinguish who comes from who? 9. When a bug removes itself from the grid, will it place a flower in its previous location? I dont think so? The flower comes out following an act method or move. So if the bug is instantaneously removed, there shouldnt be a flower there. 10. Which statement(s) in the move method places the flower in the grid in the bugs previous location? Flower flower=new Flower(getColor()); Flower.putSelfInGrid(gr,loc); 11. If a bug needs to turn 180 degrees, how many times should it call the turn method? 4 times
2007 The College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents).
1. Specify: Each group creates a class called Jumper. This actor can move forward two cells in each move. It jumps over rocks and flowers. It does not leave anything behind it when it jumps. In the small groups, discuss and clarify the details of the problem: a. What will a jumper do if the location in front of it is empty, but the location two cells in front contains a flower or a rock? If it was a bug maybe it could turn? b. What will a jumper do if the location two cells in front of the jumper is out of the grid? It could turn. c. What will a jumper do if it is facing an edge of the grid? It could turn. d. What will a jumper do if another actor (not a flower or a rock) is in the cell that is two cells in front of the jumper? It could turn, take the place of that other actor if coded to do so or nothing.
2007 The College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents).
e. What will a jumper do if it encounters another jumper in its path? It depends on the coding of the jumper. If it can eat its own then itll replace the other. f. Are there any other tests the jumper needs to make? Can Jumper go one at a time in any instance? Can it go locations with other actors? Design: Groups address important design decisions to solve the problem: g. Which class should Jumper extend? Why? It definitely extends actor. Maybe bug? It acts and sounds like one. h. Is there an existing class that is similar to the Jumper class? If so, which one? Why or why not? JumpingBug along with the original bug sounds similar to the Jumper. canMove() and in Jumpers possible case, canJump() seem to have a funny correlation. i. Should there be a constructor? Why? If yes, what parameters should be specified for the constructor? I guess there can. You can always make the jumper do extra stuff like change color or something. In that case youd need a color parameter. j. Which methods should be overridden? Why? The canMove() and move() method should be overridden because the Jumper jumps. k. What methods, if any, should be added? Why? I cant think of anything else besides move-related methods. l. What is the plan for testing the class? Just make a jumper class as well as a jumpertester. Then run the jumpertester and see if it goes.
2007 The College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents).