1 / 53

Jeopardy

Jeopardy. AP Computer Science edition GridWorld Bug Variations (Ch2). Bug. Grid. Location. Actor. BoxBug. 100. 100. 100. 100. 100. 200. 200. 200. 200. 200. Jeopardy. 300. 300. 300. 300. 300. 400. 400. 400. 400. 400. 500. 500. 500. 500. 500.

trapper
Download Presentation

Jeopardy

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Jeopardy AP Computer Science editionGridWorld Bug Variations (Ch2)

  2. Bug Grid Location Actor BoxBug 100 100 100 100 100 200 200 200 200 200 Jeopardy 300 300 300 300 300 400 400 400 400 400 500 500 500 500 500

  3. How many constructor methods does a Bug have and what do they do? Bug - 100

  4. What is the purpose of the act() method and what does it do for a standard Bug? Bug - 200

  5. When does the canMove() method return false? Bug - 300

  6. A standard Bug is facing a rock and the bug is told to move(). What will happen? Bug - 400

  7. If you create a new Bug and redefined the turn() method as follows, what would be the behavior of the bug? public void turn(){ setDirection(getDirection() * 2);} Bug - 500

  8. What is the Grid method used to retrieve an object at a location on the grid? Grid - 100

  9. In a bug class, how would you determine if Location loc is outside the grid? Grid - 200

  10. How do you create a world which has no boundaries? Grid - 300

  11. How do you create a world which has 30 rows and 30 columns? Grid - 400

  12. In a bug class how would you determine how many columns are in the world that the bug inhabits? Grid - 500

  13. What Location method(s) are used in the Bug’s move() method? Location - 100

  14. In a Bug class, how could you determine if the bug is on the first row (assume a bounded grid)? Location - 200

  15. In a Bug class, how could you determine if the bug is on a location where the row and the column were the same? Location - 300

  16. How do you determine the location directly behind the bug? Location - 400

  17. How can you determine if the object to the left of the bug is a Critter? Location - 500

  18. How do you determine the grid that the actor is located on? Actor - 100

  19. How can the bug be taken out of ActorWorld? Actor - 200

  20. How can you make the Bug move to the previous column on the same row and stay in the direction it is facing? Actor - 300

  21. What happens here?Grid<Actor> gr = new BoundedGrid(20,20);ActorWorld world = new ActorWorld(gr);world.add(new Location(2,2), new Rock);Bug ladyBug = new Bug();ladyBug.putSelfInGrid(gr, new Location(2,2));ladyBug.putSelfInGrid(gr, new Location(3,4)); Actor - 400

  22. How can you make the Bug move to the last row in the grid, stay in the same column it is in, and stay in the direction it is currently facing? Actor - 500

  23. What is the parameter passed to a new BoxBug and what does it mean? BoxBug -100

  24. What does the instance variable steps represent? BoxBug - 200

  25. What does the instance variable sideLength represent? BoxBug - 300

  26. Can the path that a BoxBug takes ever change? BoxBug – 400

  27. When will the value of steps be zero? BoxBug – 500

  28. Thanks

  29. How many constructor methods does a Bug have and what do they do? Bug – 100 (solution) 2 Constructor Methods: Bug() – creates a red bug facing north Bug(Color) - creates a bug of the specified color which faces north

  30. What is the purpose of the act() method and what does it do for a standard Bug? Bug – 200 (solution) The act() method controls the behavior of the bug. The standard behavior is that the bug moves in the direction it is facing if it can, else it turns 45 degrees to the right.

  31. When does the canMove() method return false? Bug – 300 (solution) When the border is directly in front of the bug or when another actor other than a flower is in front of the bug.

  32. A standard Bug is facing a rock and the bug is told to move(). What will happen? Bug – 400 (solution) The rock will be removed from the grid and the Bug will move to the spot where the rock was originally located

  33. If you create a new Bug and redefined the turn() method as follows, what would be the behavior of the bug? public void turn(){ setDirection(getDirection() * 2);} Bug – 500 (solution) The higher the number of degrees the bug was facing (up to 359) the more the bug would turn (by a factor of 2)

  34. What is the Grid method used to retrieve an object at a location on the grid? Grid – 100 (solution) get(Location) – It will return the object at that location, or null if there is no object at that location.

  35. In a bug class, how would you determine if Location loc is outside the grid? Grid – 200 (solution) Grid<Actor> gr = getGrid();if (!gr.isValid(loc)) ……….

  36. How do you create a world which has no boundaries? Grid – 300 (solution) ActorWorld world = new ActorWorld(new UnboundedGrid());

  37. How do you create a world which has 30 rows and 30 columns? Grid – 400 (solution) ActorWorld world = new ActorWorld(new BoundedGrid(30,30));

  38. In a bug class how would you determine how many columns are in the world that the bug inhabits? Grid – 500 (solution) Grid<Actor> gr = getGrid();int numColumns = gr.getNumCols();

  39. What Location method(s) are used in the Bug’s move() method? Location – 100 (solution) getAdjacentLocation()

  40. In a Bug class, how could you determine if the bug is on the first row (assume a bounded grid)? Location – 200 (solution) if (getLocation().getRow() == 0) …….

  41. In a Bug class, how could you determine if the bug is on a location where the row and the column were the same? Location – 300 (solution) Location loc = getLocation();if (loc.getRow() == loc.getCol()) …….

  42. How do you determine the location directly behind the bug? Location – 400 (solution) Location loc = getLocation(); Location backLoc = loc.getAdjacentLocation(getDirection()+180);

  43. How can you determine if the object to the left of the bug is a Critter? Location – 500 (solution) Grid<Actor> gr = getGrid();Location loc = getLocation(); Location leftLoc = loc.getAdjacentLocation(getDirection()-90);if (gr.get(leftLoc) instanceof Critter) ……..

  44. How do you determine the grid that the actor is located on? Actor – 100 (solution) Grid<Actor> gr = getGrid();// gr now conatins the grid that the actor is on or null if it is not on a grid.

  45. How can the bug be taken out of ActorWorld? Actor – 200 (solution) removeSelfFromGrid();

  46. How can you make the Bug move to the previous column on the same row and stay in the direction it is facing? Actor – 300 (solution) Location loc = getLocation();moveTo(new Location(loc.getRow(), loc.getCol()-1));

  47. What happens here?Grid<Actor> gr = new BoundedGrid(20,20);ActorWorld world = new ActorWorld(gr);world.add(new Location(2,2), new Rock);Bug ladyBug = new Bug();ladyBug.putSelfInGrid(gr, new Location(2,2));ladyBug.putSelfInGrid(gr, new Location(3,4)); Actor – 400 (solution) The rock is removed from location (2,2).ladyBug is put into location (2,2).An error occurs when the last line of code is executed, since ladyBug already exists in the grid.

  48. How can you make the Bug move to the last row in the grid, stay in the same column it is in, and stay in the direction it is currently facing? Actor – 500 (solution) Grid<Actor> gr = getGrid();Location loc = getLocation();moveTo(new Location(gr.getNumRows()-1, loc.getCol()));

  49. What is the parameter passed to a new BoxBug and what does it mean? BoxBug – 100 (solution) The parameter is an integer and it represents the number of steps the BoxBug takes on each side of the box.

  50. What does the instance variable steps represent? BoxBug – 200 (solution) steps is an integer that represents the number of steps the BoxBug has currently taken on a side of a box.

More Related