AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.

Slides:



Advertisements
Similar presentations
Chapter 10 Introduction to Arrays
Advertisements

Introducing While loops (and random numbers too) Alice.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
Chapter 3 Planning Your Solution
Copyright 2010 by Pearson Education 1 Assignment 11: Critters.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
ACM/JETT Workshop - August 4-5, Marine Biology Case Study (MBCS) A Discussion.
AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
CS 106 Introduction to Computer Science I 03 / 19 / 2007 Instructor: Michael Eckmann.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Algorithms and their Applications CS2004 ( ) Dr Stephen Swift 3.1 Mathematical Foundation.
111 © 2002, Cisco Systems, Inc. All rights reserved.
By the end of this session you should be able to...
1 Java: AP Curriculum Focus and Java Subset Alyce Brady.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Data Structures Using C++ 2E Chapter 8 Queues. Data Structures Using C++ 2E2 Objectives Learn about queues Examine various queue operations Learn how.
AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
1 Heaps and Priority Queues Starring: Min Heap Co-Starring: Max Heap.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Marine Biology Simulation Part II: Assignment, Milestone 1 Dung “Zung” Nguyen Mathias Ricken Stephen Wong TeachJava 2004! June 25, 2004.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Nifty Assignments: Marine Biology Simulation OOPSLA ‘04 Educators’ Symposium October 25, 2004 Eric Cheng Mathias Ricken Dung “Zung” Nguyen Stephen Wong.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
Loops Wrap Up 10/21/13. Topics *Sentinel Loops *Nested Loops *Random Numbers.
Georgia Institute of Technology Simulations Barb Ericson Jan 2005.
CS 106 Introduction to Computer Science I 10 / 29 / 2007 Instructor: Michael Eckmann.
(c) University of Washington16-1 CSC 143 Java Linked Lists Reading: Ch. 20.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Teaching with the AP ® Marine Biology Simulation Case Study Materials mostly from: Alyce Brady(Case Study Author) Kathy Larson(Case Study Teachers' Guide.
Teaching with the AP ® Marine Biology Simulation Case Study Materials mostly from: Alyce Brady(Case Study Author) Kathy Larson(Case Study Teachers' Guide.
M1G Introduction to Programming 2 5. Completing the program.
Lesson 6 – Libraries & APIs Libraries & APIs. Objective: We will explore how to take advantage of the huge number of pre-made classes provided with Java.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
(c) , University of Washington18a-1 CSC 143 Java Searching and Recursion N&H Chapters 13, 17.
March 1, 2004CS WPI1 CS 509 Design of Software Systems Lecture #6 Monday, March 1, 2004.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
Aquarium Lab Series Developed by Alyce BradyAlyce Brady of Kalamazoo CollegeKalamazoo College.
Slides prepared by Rose Williams, Binghamton University Chapter 16 Collections and Iterators.
CS 106 Introduction to Computer Science I 03 / 22 / 2010 Instructor: Michael Eckmann.
Clue Paths. Memory Alias Review Remember that it’s possible for two unique variables to point to the same memory location myList MyClass mc 0x100 someFn.
Object and Classes อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 3.
Chapter 15 Running Time Analysis. Topics Orders of Magnitude and Big-Oh Notation Running Time Analysis of Algorithms –Counting Statements –Evaluating.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
Teaching with the AP® Marine Biology Simulation Case Study
AP Case Study Overview Barbara Ericson Jan 2005
More Sophisticated Behavior
Interfaces and Inheritance
Lecture 5 from (Chapter 4, pages 73 to 96)
Graph Paper Programming
Graph Paper Programming
Review CSE116 2/21/2019 B.Ramamurthy.
Lecture 12: Message passing The Environment Model
Building a Game in Scratch
Marine Biology Simulation Part II: Assignment, Milestone 1
Presentation transcript:

AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College

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

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

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 relationship n context for covering design and testing n rich source of assignments n source of non-trivial exam questions

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

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.

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)

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

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 not available until the next day. n Pat is given instructions for running the program and told where to find data files. Chapter 1

Exercise 1 n Let’s see it run! n Complete the table on p. 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

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

One step in the simulation Chapter 2

What do core classes look like? Simulation: step method - very simple loop through all the fish (see p. 21) Simulation: step method - very simple loop through all the fish (see p. 21) n Environment: black box; only look at class documentation (until Chap 5) n Fish: u has color, direction  move method is a little more complicated, has more helper methods Chapter 2

Constructors n Initialize instance variables n Add the fish to the environment u a fish knows about its environment u must always be in an environment to be in a consistent state n See pp Chapter 2

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

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

Exercise 2 n Let’s see some sample exercises. u Do Questions 1, 7, 8, 9 on p. 31 u Read over exercises on p. 32 n What’s the difference between Analysis Questions and Exercises?

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

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

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

Breeding and Dying n Sample Exercise: Introduce a new instance variable in Fish keeping track of how many times a fish bred. Initialize it in the constructor and increment it in the breed method. Modify the debugging statement in the die method to print the number of times the fish bred. Run your simulation for 20 timesteps. What is the maximum number of times a fish bred in your test run? What is the minimum number? Are these values you would have expected given the probability of breeding in each timestep? Chapter 3

Exercise 3 n Let’s see it run!

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

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

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

Exercise 4 n Let’s see it run! n Let’s see some sample exercises. u Questions 1 and 2 on p. 75 u Read over exercises on p. 76

“A” Exam Summary n Class Implementations  Simulation (Chap 2)  Fish (Chaps 2 & 3)  DarterFish (Chap 4)  SlowFish (Chap 4) n Class Documentation u A number of utility classes

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

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

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

Exercise 5 n Let’s see it run! n Let’s see some sample exercises. u Questions 1 and 2 on p. 80 u Read over exercises on p. 104

Key Features n Introduces “large” program to intro students n Covers key topics; highlights new ones u Object interaction u Inheritance, dynamic binding u Interfaces u Design issues u Testing u Data Representation

Want to use it? n compsci/download.html