Marine Biology Simulation Part II: Assignment, Milestone 1 Dung “Zung” Nguyen Mathias Ricken Stephen Wong TeachJava 2004! June 25, 2004.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Introducing Java CSC1401. Course Goals Teaching programming concepts In a “real” language.
Marine Biology Simulation Part I: Introduction Dung “Zung” Nguyen Mathias Ricken Stephen Wong TeachJava 2004! June 25, 2004.
Games and Simulations O-O Programming in Java The Walker School
Program: Little Crab Mr Gano.
Asteroids Games and Simulations O-O Programming in Java The Walker School The Walker School – Games and Simulations
Georgia Institute of Technology DrJava Appendix A Barb Ericson Georgia Institute of Technology May 2006.
Design Patterns for Marine Biology Simulation Dung “Zung” Nguyen Mathias Ricken Stephen Wong Rice University.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Alice Variables Pepper. Set to Java look Edit / preferences restart.
Microsoft ® Office Word 2007 Training Mail Merge II: Use the Ribbon and perform a complex mail merge [Your company name] presents:
CS0007: Introduction to Computer Programming Introduction to Arrays.
What Is a Factory Pattern?.  Factories are classes that create or construct something.  In the case of object-oriented code languages, factories construct.
 What I hate about you things people often do that hurt their Web site’s chances with search engines.
Games and Simulations O-O Programming in Java The Walker School
Test. A software house decides to develop a DVD renting program. The product manager identifies the following requirements: Every DVD will have a title,
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
1 Web Based Programming Section 6 James King 12 August 2003.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Copyright 2007, Information Builders. Slide 1 WebFOCUS Maintain – Enhancing Objects with JavaScript Mark Derwin Information Builders Information Builders.
Applets Chapter 17.  Java’s big splash onto the scene came in the mid 90’s. The people at Sun Microsystems had managed to work java programs into Web.
ACM/JETT Workshop - August 4-5, Guidelines For Using BlueJ.
1 ITI 1120 Lab # 1 An Introduction to the Lab Environment Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot.
CPSC1301 Computer Science 1 Overview of Dr. Java.
Chapter 1 - Getting to know Greenfoot
Graphics Concepts CS 2302, Fall /3/20142 Drawing Paths.
Copyright © Curt Hill Turtles The beginning of media computation.
AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
Design Patterns for Marine Biology Simulation Dung “Zung” Nguyen Mathias Ricken Stephen Wong Rice University.
Nifty Assignments: Marine Biology Simulation OOPSLA ‘04 Educators’ Symposium October 25, 2004 Eric Cheng Mathias Ricken Dung “Zung” Nguyen Stephen Wong.
Programming in Java CSCI-2220 Object Oriented Programming.
Slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming – Home and reload buttons for the webbrowser, Applets.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Computer Science I Programming in Java (programming using Processing IN Java, using IntelliJ IDE) Classwork/Homework: copy your Processing projects over.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming –TextField Action Listeners, JEditorPane action listeners, HTML in a JEditorPane,
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
Introduction To Greenfoot
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
Session 7 Introduction to Inheritance. Accumulator Example a simple calculator app classes needed: –AdderApp - contains main –AddingFrame - GUI –CloseableFrame.
Aquarium Lab Series Developed by Alyce BradyAlyce Brady of Kalamazoo CollegeKalamazoo College.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
Design Patterns. Outline Purpose Purpose Useful Definitions Useful Definitions Pattern Overview Pattern Overview.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Module Road Map Refactoring Why Refactoring? Examples
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Marine Biology Simulation Part I: Introduction
Eclipse Navigation & Usage.
Testing and Debugging.
Copyright © 2008 by Helene G. Kershner
CompSci 230 Software Construction
Creating and Modifying Text part 2
Using Procedures and Exception Handling
Nifty Assignments: Marine Biology Simulation
Marine Biology Simulation Part III: Assignment, Milestone 2
Topic 1: Problem Solving
Workshop for Programming And Systems Management Teachers
Data Structures & Algorithms
More on Creating Classes
Marine Biology Simulation Part II: Assignment, Milestone 1
OOPSLA ’04 Educator’s Symposium
The beginning of media computation Followed by a demo
Workshop for Programming And Systems Management Teachers
Presentation transcript:

Marine Biology Simulation Part II: Assignment, Milestone 1 Dung “Zung” Nguyen Mathias Ricken Stephen Wong TeachJava 2004! June 25, 2004

Rice MBS Assignment Target Audience Students at the end of an objects-first CS2 Length of Assignment Two milestones Approximately 10 hours of work Probably supported by one or two labs

Studying the Case Study SimpleFish UnboundedEnv Variant Fish Behavior Variant Environment Behavior Re-implement as per given specs. White-box Framework: Extension by Subclassing

Strategy Pattern + void move() Static Behavior! Separate the variants from the invariants Studying the Case Study

Rice MBS Assignment Milestone 1 Part 1: KnightFish Add a new fish species to the simulation Part 2: WrappingEnv Add a new kind of environment Milestone 2 Part 3: Internals Re-implement parts of the simulation framework Part 4: Behavior Strategies Refactor framework to allow dynamic behavior changes

Preparation Read assignment document Download materials for Milestone 1 milestone1.zip Unzip into empty directory Open DrJava Copy your drjava.jar into the project directory

Configuring DrJava Add RiceMBSfw.jar file to “Extra Classpath” Edit, Preferences, Resource Locations Click on “Add” button Click on RiceMBSfw.jar file and “Select” Click on “OK” at the bottom of the dialog Now the framework has been added and can be used without source Make sure you run in “Full Java”

Running the Simulation In the “Interactions” pane, type java controller.MBSController Play around with the simulation Create new environment Edit environment Add fish Run simulation

Part 1: KnightFish Randomly pick one of 8 targets Example:

Part 1: KnightFish Turn into right direction Attempt one step forward If blocked, done If open, go there 3

Part 1: KnightFish Attempt a second step If blocked, done If open, go there Turn into right direction 3

3 Part 1: KnightFish Attempt the third and last step If blocked, done If open, go there

3 Part 1: KnightFish Moves almost like a knight, except… No jumping If blocked, might stop on the way Stop here

Part 1: KnightFish Complicated behavior Procedural programming: many nested if- statements Delegation method Nested visitors Cannot forget to handle a situation (compiler error!) Process flow diagramming Makes designing complex algorithm a systematic process

Part 1: KnightFish Students do this assignment Most of the code can be taken from existing examples For lack of time, we will do something simpler Fish attempts to move forward If blocked, turn around 180 degrees If open, go there Open TeachFish.java in model.fish

Part 1: KnightFish protected void move() tryMoveFwd(, ); } new ILambda() { public Object apply(Object moveCmd) { ((ILambda)moveCmd).apply(null); return null; } } Command to execute if blocked Command to execute if unblocked new ILambda() { public Object apply(Object notUsed) { turnRight(Math.PI); return null; } Ask local environment to move forward ((ILambda)moveCmd).apply(null); Tell the local environment to actually move the fish

Part 1: KnightFish Compile the file Run the simulation Create a new environment, and edit it Add a fish Select “Add…” Enter model.fish.TeachFish and hit “Create” Click somewhere on the map Run the simulation New fish class loaded at runtime!

Part 2: WrappingEnv Grid-based, bounded, and rectangular environment If the fish leaves on one side, it re-enters from the other side Topology: torus (donut)

Part 2: WrappingEnv Very similar to BoundedEnv In BoundedEnv, the Location class computes a neighboring location by adding a direction vectorto its own coordinates. The new coordinates might be inside or outside the environment. Can new coordinates ever be outside in WrappingEnv? Answer is part of class assignment and has been removed

Part 2: WrappingEnv The leftmost x-coordinate that is still inside the environment is 0. The rightmost one is (width-1). In BoundedEnv, the x-coordinate of the neighbor from there to the left is -1. What’s the x-coordinate of the left neighbor in WrappingEnv? Answer is part of class assignment and has been removed

Part 2: WrappingEnv The necessary changes are centralized in a single method, WrappingEnv.Location.getNeighbor. Since BoundedEnv and WrappingEnv are so similar, what OO technique can we apply to maximize code-reuse? Answer is part of class assignment and has been removed

Part 2: WrappingEnv Need to write constructors The framework uses factory methods Abstract creation To complete the environment, we have to override the factory methods WrappingEnv.makeLocation WrappingEnv.makeEnvFactory (code provided for makeEnvFactory) Students’ code is still based on existing code, but cannot simply be copied and modified anymore

Part 2: WrappingEnv Open WrappingEnv.java in sysModel.env The project was split into “model” and a “sysModel” packages to clearly separate system code (environments) from user code (fish) Fish more likely to get changed than environments Edit the WrappingEnv.Location.getNeighbor method Students would have to do a little bit more

Part 2: WrappingEnv Code is part of a class assignment and has been removed

Part 2: WrappingEnv Compile the file Run the simulation Create a new environment Select “Add…” Enter sysModel.env.WrappingEnv and hit “Create” Pick a size and create the environment Add fish Run the simulation

End of Milestone 1 Students submit code for Part 1 and Part 2 Material for Milestone 2 gets released after submission deadline Contains solutions for Milestone 1