gridworld case study part 2 bug variations a summary by jim mims
TRANSCRIPT
![Page 1: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims](https://reader036.vdocuments.us/reader036/viewer/2022082701/5515100355034673228b4945/html5/thumbnails/1.jpg)
GridWorld Case Study
Part 2
Bug Variations
A Summary by Jim Mims
![Page 2: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims](https://reader036.vdocuments.us/reader036/viewer/2022082701/5515100355034673228b4945/html5/thumbnails/2.jpg)
Contents
Introduction
Part 1: Observing and Experimenting with GridWorld
Part 2: Bug Variations
Part 3: GridWorld Classes and Interfaces
Part 4: Classes that Extend the Critter Class
Part 5: Grid Data Structures
![Page 3: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims](https://reader036.vdocuments.us/reader036/viewer/2022082701/5515100355034673228b4945/html5/thumbnails/3.jpg)
Classes and Interfaces: Relationships
![Page 4: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims](https://reader036.vdocuments.us/reader036/viewer/2022082701/5515100355034673228b4945/html5/thumbnails/4.jpg)
Introduction
The case study provides a graphical environment where visual objects inhabit and interact in a two-dimensional grid.
Students design and creator actor objects, add them to a grid, and determine whether they behave according to specifications.
![Page 5: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims](https://reader036.vdocuments.us/reader036/viewer/2022082701/5515100355034673228b4945/html5/thumbnails/5.jpg)
Bug Class Methods
public boolean canMove() tests whether the bug can move forward into a location that is empty or contains a flower
public void move() moves the bug forward, putting a flower into the location it previously occupied
public void turn() turns the bug 45 degrees to the right without changing its position
![Page 6: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims](https://reader036.vdocuments.us/reader036/viewer/2022082701/5515100355034673228b4945/html5/thumbnails/6.jpg)
Extending Bug Class – BoxBug Class
Moves in a square pattern No new methods need to be added
Act method uses the 3 methods listed previously BoxBug class has 2 instance variables, sideLength and steps
![Page 7: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims](https://reader036.vdocuments.us/reader036/viewer/2022082701/5515100355034673228b4945/html5/thumbnails/7.jpg)
Runner Classes
A runner class is added to observe the behavior of one or more actors Runner class constructs an ActorWorld object places actors in it shows the world
Act method uses the 3 methods listed previously For the bug, this class is BugRunner When you write your own classes that extend bug, you need to create a similar runner class
![Page 8: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims](https://reader036.vdocuments.us/reader036/viewer/2022082701/5515100355034673228b4945/html5/thumbnails/8.jpg)
BoxBug Runner