Download presentation
Presentation is loading. Please wait.
Published byAdrian Lockhart Modified over 11 years ago
1
GridWorld Case Study Part 3 GridWorld Classes and Interfaces A Summary by Jim Mims
2
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
3
Classes and Interfaces: Relationships
4
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.
5
GridWorld Classes and Interfaces: Location Class Encapsulates coordinates for an actors position in the grid Every actor has a position and a direction Class provides 8 constants that specify compass directions Class provides 7 constants for turn directions
6
GridWorld Classes and Interfaces: Grid Interface Specifies the method for any grid that contain objects of type E BoundedGrid and UnboundedGrid implement the interface Methods allow you to put objects into a grid remove them get reference to an object in the grid Four other methods are used to collect information ref neighbors
7
GridWorld Classes and Interfaces: Actor Class Accessor methods provide information concerning state of the actor getColor getDirection) getGrid() getLocation() Mutator methods enable an actor to add or remove itself from a grid putSelfInGrid() removeSElfFromGrid() Additional methods that can be used setColor() setDirection() act()
8
GridWorld Classes and Interfaces: Extending Actor Class Bug, Flower, Rock classes override act method of the Actor class The behavior of these class is specified by how they override act()
9
Graphical User Interface is Not Tested World class makes connection between GUI and classes that are tested ActorWorld is a subclass of World ActorWorld provides a step method that invokes act on each actor Other worlds can be defined that contain occupants other than actors
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.