Marine Biology Case Study (MBCS) - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Marine Biology Case Study (MBCS)

Description:

Marine Biology Case Study (MBCS) A Discussion Marine Biology Case Study Simulation Program We are now ready to study the design and the core concepts used in the ... – PowerPoint PPT presentation

Number of Views:156
Avg rating:3.0/5.0
Slides: 19
Provided by: scu66
Category:
Tags: mbcs | biology | case | fish | marine | study

less

Transcript and Presenter's Notes

Title: Marine Biology Case Study (MBCS)


1
Marine Biology Case Study (MBCS)
  • A Discussion

2
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.

3
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. 

4
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

5
MBCS Class diagram
  • Let us see an UML class diagram showing the most
    important classes and interfaces in MBCS.

6
MBCS Class Diagram with the core classes
7
Details
  • We will now take a detailed look at how the
    concepts were used in the code.

8
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.
9
Use of interfaces
The class Fish implements the Locatable
interface. Therefore, it has to provide the
code/implementation for the method, location().
10
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)
11
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
12
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.
13
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()
14
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
Locatable3 allObs0 new
Fish() allObs1 new SlowFish() allObs2
new DarterFish() allObs1.location() allObs0
.move() allObs2.move()
15
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.
16
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)
17
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.
  • Class Fish has an instance variable called
    theEnv.
  • The Fish object is adding itself to the
    Environment object, theEnv.
  • Using this constructor, I am creating an instance
    of a Fish
  • Fish myFish new Fish (new BoundedEnv())
  • Will the above statement compile?

18
Demo
  • Let us now run the simulation of MBCS.
Write a Comment
User Comments (0)
About PowerShow.com