1 / 13

Presentation by Denis Riordan, Dalhousie University Objects and Classes

Presentation by Denis Riordan, Dalhousie University Objects and Classes. Object modeling is a modeling mechanism that maximizes the commonality between situations. Where do we start the modeling process?. What do these objects have in common?. Taxonomic Hierarchy. Hierarchical Extensions.

efia
Download Presentation

Presentation by Denis Riordan, Dalhousie University Objects and Classes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Presentation by Denis Riordan, Dalhousie University Objects and Classes

  2. Object modeling is a modeling mechanism that maximizes the commonality between situations.

  3. Where do we start the modeling process? What do these objects have in common? Taxonomic Hierarchy

  4. Hierarchical Extensions Purpose: Avoiding Redundancy by using commonality A component B in an hierarchy lies below (extends) another component A if B has all the properties of A Elephants and rhinoceros share the properties of Chordates Locusts and elephants share the properties of Animalia

  5. Class Creation in Java In Java the components of an inheritance hierarchy are called classes. In class definitions are created using the following syntax class ChosenName { // Details }

  6. Class Hierarchical Creation in Java A class A may be extended to create a class B using the following syntax class B extends A { // Details } In Java all class definitions by default extend the universal class which is called Object (just to be as confusing as possible).

  7. Example of class hierarchical extensions in Java class Animalia { //... } class Chordata extends Animalia { //... } class Mamalia extends Chordata { //.. }

  8. Definitions: Classes and Objects • Classes – define object type - blue prints - specifications • An object is the thing itself • This means that there may be many objects of a particular class

  9. Many objects of the same class class Ant{} Ant a1 = new Ant();

  10. Constructing objects in Java In Java a new object is constructed using the following syntax: ClassName objectName = new ClassName(); or ClassName objectName = new ClassName(parameters); Example Ant a1 = new Ant(); Robot r1 = new Robot(Color.red);

  11. Abstract Classes A class is defined to be abstract if it is intended that it should always be extended (perhaps because there might not normally be an object of that type). abstract class Shape {} class Triangle extends Shape {} Might still be abstract!

  12. Angry rhino object chases annoying photographer Exercise on Object Modelling OMEx.doc

  13. And finally Thank you all for your attention Photography by Denis Riordan

More Related