gridworld case study part 2 bug variations a summary by jim mims

8
GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims

Upload: maya-coughlin

Post on 27-Mar-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims

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

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

Classes and Interfaces: Relationships

Page 4: GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims

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

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

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

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

BoxBug Runner