ACM/JETT Workshop - August 4-5, 2005 1 Marine Biology Case Study (MBCS) A Discussion.

Slides:



Advertisements
Similar presentations
ACM/JETT Workshop - August 4-5, Classes, Objects, Equality and Cloning.
Advertisements

Chapter 1 Object-Oriented Concepts. A class consists of variables called fields together with functions called methods that act on those fields.
Inheritance Inheritance Reserved word protected Reserved word super
Slides 4/22 COP Topics Final Exam Review Final Exam The final exam is Friday, April 29 th at 10:00 AM in the usual room No notes, books, calculators,
ACM/JETT Workshop - August 4-5, :Inheritance and Interfaces.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Interface COMP T1.
Session 07: C# OOP 4 Review of: Inheritance and Polymorphism. Static and dynamic type of an object. Abstract Classes. Interfaces. FEN AK - IT:
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Rossella Lau Lecture 6, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 6: More on class construction UML and an.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
1 Generics and Using a Collection Generics / Parameterized Classes Using a Collection Customizing a Collection using Inheritance Inner Classes Use of Exceptions.
UML Class Diagram: class Rectangle
Chapter 10 Classes Continued
UML class diagrams (1) UML = Unified Modeling Language We use only class diagrams, not other UML diagrams Purpose: –keep OO concepts separate from implementation.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-Oriented Analysis and Design
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.
Georgia Institute of Technology Extending the Case Study Barbara Ericson January 2005.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
ACM/JETT Workshop - August 4-5, Guidelines For Using BlueJ.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
1 Generics and Using a Collection Generics / Parameterized Classes Using a Collection Customizing a Collection using Inheritance Inner Classes Use of Exceptions.
AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
Modern Software Development Using C#.NET Chapter 5: More Advanced Class Construction.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Object-Oriented Programming. An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.
CS 106 Introduction to Computer Science I 04 / 23 / 2010 Instructor: Michael Eckmann.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Object Oriented Software Development
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
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.
ACM/JETT Workshop - August 4-5, : Defining Classes in Java.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
List Interface and Linked List Mrs. Furman March 25, 2010.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 1 Chapter 15 Abstract Classes and Interfaces.
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
Lecture 5:Interfaces and Abstract Classes Michael Hsu CSULA.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Lecture 6:Interfaces and Abstract Classes Michael Hsu CSULA.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Modern Programming Tools And Techniques-I
Sections Inheritance and Abstract Classes
Object-Oriented Modeling
Interface Java 7 COMP T1.
Interface, Subclass, and Abstract Class Review
Inheritance and Polymorphism
UML Class Diagram: class Rectangle
Interfaces and Inheritance
Object Oriented Programming
Chapter 19 Generics Dr. Clincy - Lecture.
Java Programming Language
Decorator Pattern Richard Gesick.
Advanced Programming in Java
CS 112 Programming 2 Lecture 02 Abstract Classes & Interfaces (2)
Presentation transcript:

ACM/JETT Workshop - August 4-5, Marine Biology Case Study (MBCS) A Discussion

ACM/JETT Workshop - August 4-5, Marine Biology Case Study Simulation Program We are now ready to study the design and the core concepts used in the implementation of MBCS. The lectures in the last two days have covered most of the concepts used in this program. Because of time constraints, I will highlight the areas in this simulation study where the concepts were used.

ACM/JETT Workshop - August 4-5, MBCS – What is it? The Advanced Placement® Marine Biology Simulation case study is a Simulation program Designed to help marine biologists study fish movement in a small, bounded environment such as a lake or bay.

ACM/JETT Workshop - August 4-5, MBCS – Concepts Used In this simulation program, a number of concepts that we covered in the lectures were used. I will list some of them. Classes with multiple constructors Classes with access methods Inheritance Abstract classes Interfaces Composition (containment) using Arrays, ArrayLists Comparing objects using equals() Exceptions Graphic User Interface

ACM/JETT Workshop - August 4-5, MBCS Class diagram Let us see an UML class diagram showing the most important classes and interfaces in MBCS.

ACM/JETT Workshop - August 4-5, MBCS Class Diagram with the core classes

ACM/JETT Workshop - August 4-5, Details We will now take a detailed look at how the concepts were used in the code.

ACM/JETT Workshop - August 4-5, Use of interfaces Locatable is an interface that has a method declaration for location() which returns a Location. The interface as a contract guarantees that any object of a class that implements this interface knows its location and returns it when the location() method is called.

ACM/JETT Workshop - August 4-5, Use of interfaces The class Fish implements the Locatable interface. Therefore, it has to provide the code/implementation for the method, location().

ACM/JETT Workshop - August 4-5, Use of interfaces Test your understanding An instance of class Fish is also an instance of type Locatable. (True or False) Locatable locatable = new Locatable(); Will this compile? Locatable locatableOb = new Fish(); Will this compile? If a method accepts a parameter of type Locatable, you can call that method with an object of type Fish. (True or False)

ACM/JETT Workshop - August 4-5, Use of interfaces Test your understanding An instance of class Fish is also an instance of type Locatable. Locatable lOb = new Fish(); lOb.location(); Will this compile? lOb.move(); Will this compile? If not, how would you fix it? l

ACM/JETT Workshop - August 4-5, Use of inheritance Classes DarterFish and SlowFish are subclasses of Fish. Why was inheritance used? DarterFish and SlowFish are both Fish. Common properties as Fish: id, color, location, direction, how they breed and die. Important differences are how they move and the types of fish they breed. Inheritance was used to avoid repeating the code to make use of common features among the classes. Since the behavior of move() and generateChild() are different in the subclasss, overriding is used to redefine the code for these methods in DarterFish and SlowFish.

ACM/JETT Workshop - August 4-5, Use of inheritance Test your understanding Will these following statements compile? Mark Ok or not OK. Fish oneFish = new Fish(); oneFish = new DarterFish(); oneFish = new SlowFish(); Locatable lOb = oneFish; Locatable lOb2 = new DarterFish();

ACM/JETT Workshop - August 4-5, Use of inheritance Test your understanding Fish oneFish = new DarterFish(); oneFish.move(); //Is it move() in //Fish or move()in //DarterFish? // Are these statements ok? Locatable [] allObs = new Locatable[3]; allObs[0] = new Fish(); allObs[1] = new SlowFish(); allObs[2] = new DarterFish(); allObs[1].location(); allObs[0].move(); allObs[2].move();

ACM/JETT Workshop - August 4-5, Using Inheritance and Interfaces Environment is an interface. SquareEnvironment is an abstract class because it does not implement all the methods in Environment. The class BoundedEnv implements the environment as a 2-dimensional array. The class UnBoundedEnv implements the environment as an ArrayList. Why? Arrays cannot change size after they are constructed. ArrayList is a dynamic data structure that can grow and shrink.

ACM/JETT Workshop - August 4-5, Using Composition A Fish object contains an Environment object, theEnv. And an Environment object maintains a collection of Fish objects. Assume the constructor for class Fish is as follows: public Fish (Environment env){ theEnv = env; theEnv.add(this); }

ACM/JETT Workshop - August 4-5, Using Composition Test your understanding public Fish (Environment env) theEnv = env; theEnv.add(this); } From the above constructor, I can conclude the following: Mark the statements OK or NotOK. 1.Class Fish has an instance variable called theEnv. 2.The Fish object is adding itself to the Environment object, theEnv. 3.Using this constructor, I am creating an instance of a Fish: Fish myFish = new Fish (new BoundedEnv()); Will the above statement compile?

ACM/JETT Workshop - August 4-5, Demo Let us now run the simulation of MBCS.