Presentation is loading. Please wait.

Presentation is loading. Please wait.

Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.

Similar presentations


Presentation on theme: "Marine Biology Simulation Case Study Alyce Brady Kalamazoo College."— Presentation transcript:

1 Marine Biology Simulation Case Study Alyce Brady Kalamazoo College

2 Case Study as Educational Tool n describes a real situation n provides an interesting example from which to draw certain lessons n provides a context for comparing theoretical ideas against real-world experience

3 Case Studies in AP CS n try to give the illusion of being a real-world situation (MBCS) or real-world tool (BigInt) n must be simplified and cleaned-up enough to be readable and understandable for HS students

4 Benefits of an AP CS case study n example of a largish program n opportunity to discuss tradeoffs (design, performance issues, readability, etc) n example of good coding, design, and documentation practice n approximation of master/apprentice n rich source of assignments n source of non-trivial exam questions

5 Alyce’s Additions n describe the development or modification of a program, not just a finished product n cover design n cover testing

6 Goals for Java MBS n provide benefits described in prev. slides n be similar to C++ MBCS u u teachers can pick it up faster u u can use it as they learn Java n be different from C++ MBCS u highlight differences in language u highlight differences in curriculum

7 The Story n A CS student, Pat, gets a summer job working for marine biologists. n Hired to enhance an existing program that simulates fish movement in a bounded environment. u Needs to understand existing program u Designs, codes, and tests modifications n Occasionally Pat turns to an experienced programmer, Jamie, for help. n Narrative is Pat’s report of summer job.

8 The Package n Code for the “existing” program u Source for core classes u Jar files for “black box” & GUI classes n Javadoc documentation for most classes n Data Files n Instructions for compiling/running n Narrative (pdf file)

9 The Modules (Chapters) n Experiment with existing program n Guided tour of existing program by Jamie n Add breeding and dying n Add two new kinds of fish (inheritance) n Provide alternative representations (unbounded environment, others)

10 First Day on the Job n “[The program] was designed to help the marine biologists study fish movement in a bounded environment, such as a lake or a bay.” n Jamie available the next day. n Given instructions for running it and told where to find data files. Chapter 1

11 Guided Tour n “The biologists think of the environment as a rectangular grid, with fish moving from cell to cell in the grid. Each cell contains zero or one fish.” Chapter 2

12 What classes are necessary? To model fish swimming in a bounded environment, the program has Fish objects and an Environment object. To model fish swimming in a bounded environment, the program has Fish objects and an Environment object. The purpose of the program is to simulate fish moving in the environment, so the program also has a Simulation object. The purpose of the program is to simulate fish moving in the environment, so the program also has a Simulation object. n There are other useful, but less important "utility classes." Chapter 2

13 One step in the simulation Chapter 2

14 What do core classes look like? n Simulation: almost identical to C++ MBCS n Environment: black box; only look at class documentation (think header file!) n Fish: u has color, direction  move method is a little more complicated, has more helper methods Chapter 2

15 move method Get next location to move to (call nextLocation ) Get next location to move to (call nextLocation ) n If next location is different from this location,  move there (call changeLocation )  change direction (call changeDirection ) Chapter 2

16 nextLocation method Get list of empty neighboring locations (call emptyNeighbors ) Get list of empty neighboring locations (call emptyNeighbors ) n Remove location behind fish from list n If there are any empty neighbors left, randomly choose one; otherwise return current location Chapter 2

17 Breeding and Dying n Problem Specification: A fish should... u have a 1 in 7 chance of breeding, u breed into all empty neighboring locations, u attempt to move when it does not breed, u never move backwards, and u have a 1 in 5 chance of dying after it has bred or moved. Chapter 3

18 Breeding and Dying Pseudo-code for act method if this is the 1 in 7 chance of breeding if this is the 1 in 7 chance of breeding call the breed method call the breed method else else call the move method call the move method if this is the 1 in 5 chance of dying if this is the 1 in 5 chance of dying call the die method call the die method Chapter 3

19 Breeding and Dying n Test Plan u Testing random behavior (Chap 2) u Black-box testing u Code-based testing Chapter 3

20 Specialized Fish n Different patterns of movement  Darters ( DarterFish )  Slow fish ( SlowFish ) n Inheritance n Dynamic Binding Chapter 4

21 Specialized Fish DarterFish DarterFish u darts two cells forward if possible u or darts one cell forward u or reverses direction (without moving) Chapter 4

22 Specialized Fish SlowFish SlowFish u has only a 1 in 5 chance of moving out of current cell  otherwise movement is the same as Fish Chapter 4

23 Classes for A Exam n Class Implementations  Simulation  Fish (as modified in Chapter 3)  DarterFish  SlowFish n Class Documentation u A number of utility classes

24 Environment Implementations n Multiple environment implementations u Environment Interface u Bounded: 2D array (matrix) -- existing u Unbounded: ArrayList of Fish -- Pat develops this implementation Chapter 5

25 Environment Implementations n Exercises u Very large bounded environment (list or sparse matrix) u Sorted list for unbounded environment with binary search u BST for unbounded environment u Hash map for unbounded environment Chapter 5

26 Classes for AB Exam n Classes and documentation from A Exam n Additional Class Interfaces/Implementations  Environment  BoundedEnv  UnboundedEnv n Class Documentation u One new utility class

27 Key Features n Overall design & core classes are similar n Discussion of modification/development allows focus on design and testing n Highlights new/different language features n Highlights new topics in curriculum u Inheritance, dynamic binding u Interfaces

28 Want to use it? n www.collegeboard.com/ap/students/ compsci/download.html


Download ppt "Marine Biology Simulation Case Study Alyce Brady Kalamazoo College."

Similar presentations


Ads by Google