Download presentation
Presentation is loading. Please wait.
Published byFelix Pearson Modified over 8 years ago
1
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
2
“AP Computer Science with.NET and J#” Lecture 11: The Marine Biology Simulation Case Study Microsoft.NET Workshops for Teachers
3
11-3 MicrosoftAP Computer Science with.NET and J# Workshop Track LectureTopic 7Algorithms and Algorithm Analysis 8Debugging and Exception Handling 9Applying Object-oriented Design Principles in Your Classes 10Using Inheritance to Design a Set of Classes 11MBS CS: the Marine Biology Simulation Case Study 12Extending the MBS CS 13Interfaces and Interface-based Programming 14Extending the MBS CS, Part 2 15Stacks, Queues and Invariants 16Linked Data Structures and the Linked-list 17Trees and Recursion 18Collection Classes and Iteration 19Additional Resources and Ideas
4
11-4 MicrosoftAP Computer Science with.NET and J# Lecture — Objectives “A lot can be learned from the study of a realistic application. The AP Marine Biology Simulation serves this role, demonstrating OO design techniques in the creation of a flexible, extensible framework for student exploration. Both AP CS exams expect students to be familiar with this case study, its core classes, and their methods. It’s mandatory that instructors cover this material...” Topics: –Overview of MBS CS –Architecture of.NET Version –Class Design [ Joe Hummel, Lake Forest College ]
5
11-5 MicrosoftAP Computer Science with.NET and J# Part 1 Overview…
6
11-6 MicrosoftAP Computer Science with.NET and J# The AP Marine Biology Simulation The AP MBS is a case study of a real application –in theory it simulates a marine environment filled with fish –in reality it’s a framework for student exploration
7
11-7 MicrosoftAP Computer Science with.NET and J# Goals The AP MBS has a number of goals for students: –work with a large program –read source code written by others –see good design in action –appreciate good documentation –consider testing in a non-trivial context –encounter implementation trade-offs –approximate the apprentice experience
8
11-8 MicrosoftAP Computer Science with.NET and J# Resources General information about AP MBS CS: –http://www.collegeboard.com/student/testing/ap/subjects.htmlhttp://www.collegeboard.com/student/testing/ap/subjects.html –http://apcentral.collegeboard.comhttp://apcentral.collegeboard.com –" MBCS Narrative " for students –" MBCS Instructor's Guide " for teachers –hundreds of pages of info… MBS CS originally developed by Alyce Brady and others J# is a port of original version to J# and.NET: –http://msdn.microsoft.com/vjsharp/using/academic/mbs/http://msdn.microsoft.com/vjsharp/using/academic/mbs/ –core classes are pure Java & identical to original version –runs in Visual Studio 2005 –[ Can’t find download? Also included in lecture’s “Demos” folder. ]
9
11-9 MicrosoftAP Computer Science with.NET and J# Approach The MBCS Narrative presents case study as series of chapters: 1. experiment with simulation program 2. tour program's internal architecture 3. modify an existing class so fish breed, and die 4. use inheritance to introduce specialized fish 5. introduce memory-efficient environment through an interface Chapters 1-4 are covered on AP CS A exam Chapters 1-5 are covered on AP CS AB exam
10
11-10 MicrosoftAP Computer Science with.NET and J# Getting Started 1.Download J# version of AP Marine Biology Case Study: –http://msdn.microsoft.com/vjsharp/using/academic/mbs/http://msdn.microsoft.com/vjsharp/using/academic/mbs/ 2.Install by double-clicking APCaseStudy-MBS.msi file 3.Start, Programs, MBS Case Study…, Visual J#.NET Solution 4.Opens in Visual Studio 2005, press F5 to compile & run…
11
11-11 MicrosoftAP Computer Science with.NET and J# Experiment… You need fish, and fish need an environment in which to live… File >> Open for existing envs –"onefish" –"fish" –etc. File >> Create to create your own –bounded (aquarium) or unbounded (ocean!) –select type & color of fish from drop-downs –click on empty cells to create fish Run simulation!
12
11-12 MicrosoftAP Computer Science with.NET and J# Demo! Running the MBS CS…
13
11-13 MicrosoftAP Computer Science with.NET and J# Part 2 Architecture…
14
11-14 MicrosoftAP Computer Science with.NET and J# It’s a Large Application AP MBS app has 4 components: –MBSCore :core classes (pure Java, students work on this code) –MBSBB :black box classes (pure Java, support code) –MBSEnvGUI :.NET UI control (support code for user interface) –MBSGUI :.NET Windows application (i.e. the forms) MBSCore.dll MBSGUI.exe MBSBB.dll environment.dat MBSEnvGUI.dll
15
11-15 MicrosoftAP Computer Science with.NET and J# Visual Studio.NET Solution Installed into “ C:\Program Files\MBS Case Study for Visual J#.NET ” –open “ Code ” sub-folder –each component is a separate VS Project / sub-folder
16
11-16 MicrosoftAP Computer Science with.NET and J# Opening the Solution Use Start menu, or double-click on.sln file This is what you'll see: –MBSBB hidden by default –students open & work on MBSCore project –students can safely ignore MBSEnvGUI & MBSGUI –CustomResXGenerator rebuilds resource file when you extend app with new images, etc. –to run, press F5 as usual!
17
11-17 MicrosoftAP Computer Science with.NET and J# Demo! The Visual Studio Solution…
18
11-18 MicrosoftAP Computer Science with.NET and J# This Looks Complex? Like most real apps, they look complex at first But you can safely ignore most of the code –this is the beauty of a good, component-based design! Students are meant to focus on MBSCore classes –and ignore the rest…
19
11-19 MicrosoftAP Computer Science with.NET and J# Part 3 Design…
20
11-20 MicrosoftAP Computer Science with.NET and J# Overview of the Core Fish classes: –Fish move around in an environment –Fish are uniquely identified by an ID –Fish also have a location, a direction and a color –MBS ships with two fish: Darter and Slow Environment classes: –An environment has a data structure to keep track of the fish –MBS ships with two environments: bounded & unbounded Simulation class: –Contains the code to drive the simulation
21
11-21 MicrosoftAP Computer Science with.NET and J# public static void main(…) { // create environment, then add fish to environment… BoundedEnv env = new BoundedEnv(5, 10); Fish f1 = new Fish(env, new Location(1, 2)); Fish f2 = new Fish(env, new Location(1, 4)); Fish f3 = new Fish(env, new Location(3, 2)); // create display with 1 sec simulation delay (1000 ms) SimpleMBSDisplay display; display = new SimpleMBSDisplay(env, 1000); // now create simulation, which will contain env, fish, & display… Simulation sim = new Simulation(env, display); while (true) // run indefinitely… sim.step(); } //main public static void main(…) { // create environment, then add fish to environment… BoundedEnv env = new BoundedEnv(5, 10); Fish f1 = new Fish(env, new Location(1, 2)); Fish f2 = new Fish(env, new Location(1, 4)); Fish f3 = new Fish(env, new Location(3, 2)); // create display with 1 sec simulation delay (1000 ms) SimpleMBSDisplay display; display = new SimpleMBSDisplay(env, 1000); // now create simulation, which will contain env, fish, & display… Simulation sim = new Simulation(env, display); while (true) // run indefinitely… sim.step(); } //main Main Program Here's the rough idea:
22
11-22 MicrosoftAP Computer Science with.NET and J# Simulation Class Each step of simulation gets fish to “act”… public class Simulation { private Environment theEnv; private EnvDisplay theDisplay;. public void step() { Locatable[] fish = theEnv.allObjects(); // fish in env… for (int i=0; i<fish.length; i++) // for each fish, act… { Fish f = (Fish) fish[i]; f.act(); // fish may move, eat, breed, die, do nothing, … } theDisplay.showEnv(); // now draw result of fish acting up! } } //class public class Simulation { private Environment theEnv; private EnvDisplay theDisplay;. public void step() { Locatable[] fish = theEnv.allObjects(); // fish in env… for (int i=0; i<fish.length; i++) // for each fish, act… { Fish f = (Fish) fish[i]; f.act(); // fish may move, eat, breed, die, do nothing, … } theDisplay.showEnv(); // now draw result of fish acting up! } } //class
23
11-23 MicrosoftAP Computer Science with.NET and J# Summary Case studies are an important tool for learning AP Marine Biology Simulation is a good app to study –component-based –elegant object-oriented design –large and complex enough to yield non-trivial study –lots of room for exploration The J# version of the AP MBS CS was ported properly: –pieces which must be pure Java remain pure Java –pieces that could be rewritten were rewritten to use.NET e.g. the GUI is based on.NET Framework Class Library, not JCL
24
11-24 MicrosoftAP Computer Science with.NET and J# Resources Web site for slides, demos, associated lab exercises: –http://blogs.msdn.com/daryllmc/default.aspxhttp://blogs.msdn.com/daryllmc/default.aspx –http://www.lakeforest.edu/~hummel/workshops-HS.htmhttp://www.lakeforest.edu/~hummel/workshops-HS.htm –https://www.mainfunction.com/home/training/https://www.mainfunction.com/home/training/
25
11-25 MicrosoftAP Computer Science with.NET and J# That’s it! Next up: LectureTopic.. 12Extending the MBS CS......
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.