Inheritance CS 2302 SPRING 2015. Inheritance In this part we introduce a new relationship between classes: inheritance. This is the fundamental feature.

Slides:



Advertisements
Similar presentations
Biological Classification
Advertisements

Classification.  What would you call this animal?  Gorilla  Monkey  Chimp  Beringei.
Linnaeus’ Taxonomy Taxonomy is any method of classification.
18.1 Finding Order in Diversity
Classifying the Diversity of Life – Systematics: Study of the diversification of living forms, both past and present, and their relationships – Taxonomy:
Classification of Living Things Chapter 7. Why There is a Need for Classifying There are well over 2 million different types of organisms known.
Clades and Classes. Classification Methods By ecology By form By ancestry.
Lecture 17 Abstract classes Interfaces The Comparable interface Event listeners All in chapter 10: please read it.
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Design Patterns in Java Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
Classification Study Guide Helps communicate with other scientists Learn how organisms are related to other organisms Learn about organisms Make sense.
TAXONOMY Presentation made by: sakura023. Need to Classify.
WHAT IS INHERITANCE? Java Unit 11: Inheritance I.
Science 7.  Explain why biologists classify organisms.  Relate the levels of classification to the relationships between organisms.  List characteristics.
1. Explain the term “taxonomy” 2. Explain the necessity for classifying living things 3. Identify the scientist that developed the current classification.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Taxonomy “The Study of Classification”. What do you think?  What does classification mean?  Why is classification important?  When do we use classification.
17.1 THE HISTORY OF CLASSIFICATION
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA Prof. Dr. Paulo Brasko Ferreira Fall 2014.
Living or Non? 1. Cells 2. Use Energy 3. Reproduce 4. Movement 5. Grow and Develop 6. Breath and Respire 7. Homeostasis (balance)
Hominid Evolution & Classification
1 Object-Oriented Programming (Java), Unit 12 Kirk Scott.
Organizing the Diversity of Life Chapter 2 Lecture Outline.
Classification of Organisms BIO Ch. 17. Ch. 17, section 1: Classification of Organisms -Taxonomy is the science of describing, naming, and classifying.
Biological Classification 1 This chart shows one idea of how humans are related to some other non- living species time Our species.
1 Object-Oriented Programming (Java), Unit 12 Kirk Scott.
The Linnean system, first formally proposed by Linneaus in Systema naturae in the 18th century, has two main characteristics. –Each species has a two-part.
UNIT 6 - Evolution SWBAT compare the relatedness of various species by applying taxonomic principles (cladistics, phylogeny, morphology and DNA.
Classification Notes. Scientists classify organisms based upon similarities.
18-1 Finding Order in Diversity. To study the diversity of life, biologists use a system of classification to logically name and group organisms based.
Modern Evolutionary Classification Chapter The Problem with the Linnaeus System Linnaeus classified organisms based on overall similarities and.
Chapter 8 Inheritance. 2  Review of class relationships  Uses – One class uses the services of another class, either by making objects of that class.
KINGDOM ANIMALIA roundworm flatworm Snail Segmented worm Sea Sponge
Chapter 17: The History and Diversity of Life
Classification Systems
CLASSIFICATION Taxonomy – to classify and name organisms. It is a science. Why?? To name and group organisms.
Classification. What is Classification? Biologists want to better understand organisms so they organize them. Classification = the grouping of objects.
Classification Current number of species identified on Earth: 1.7 million Write down all notes in BLACK text.
Chapter 18 Classification 18-1 Finding Order in Diversity.
*Refer to Chapter 5 in your Textbook. Learning Goals: 1. I can list the traditional classification hierarchy in order. 2. I can explain what binomial.
Use a simple classification key to identify an unknown organism.
CLASSIFYING ANIMALS OCS Biology. Classifying Animals Biologists divide animals into groups based on their similarities. Biologists divide animals into.
Reconstructing and Using Phylogenies 16. Concept 16.1 All of Life Is Connected through Its Evolutionary History All of life is related through a common.
CS 116 Object Oriented Programming II Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
NEW CHAPTER TOPIC: TAXONOMY.
People’s Place in Nature
Class Inheritance Part I
People’s Place in Nature
People’s Place in Nature
Evidence for evolution
Genus & Species- Homo sapiens
ESSENTIAL QUESTION: What is taxonomy?
Taxonomy Thursday, January 8th, 2015.
Unit 1: Diversity of Living Things
CLASSIFICATION.
Software Engineering Lecture #11.
CLASSIFICATION.
Biological Classification
CLASSIFICATION.
Classification Grouping Like Organisms.
Systematics Systematics is the science of categorizing organisms into like groups and establishing their relationship relative to each other. Eight major.
Let’s Classify!.
CLASSIFICATION.
Chapter 11 Inheritance and Polymorphism
TAXONOMY.
Taxonomy review.
Organizing Life's Diversity
Taxonomy The branch of science concerned with classification,
CLASSIFICATION.
Human Evolution.
Presentation transcript:

Inheritance CS 2302 SPRING 2015

Inheritance In this part we introduce a new relationship between classes: inheritance. This is the fundamental feature of object-oriented programming. The basic concepts of inheritance are discussed, and the first example from the book is recreated. 1/12/2015CS 2302-SPRING

Motivation When modeling objects, we group similar objects into *classes* We may notice that some classes of objects have common features Or, we may decide that it would be useful to subdivide and existing class into smaller groups with more specific characteristics In either case we have the idea of *subclasses*: classes that are contained in larger classes 1/12/2015CS 2302-SPRING

Taxonomy "the branch of science concerned with classification, especially of organisms; systematics." (Google) Most of us have studied taxonomy in biology: phyla, genera, species and other groups of living things The various levels of biological taxonomy show the subclass relationship 1/12/2015CS 2302-SPRING

Classification of Humans Here are the various levels of biological classes/taxa to which we human beings are assigned. Animalia (Kingdom) ◦Chordata (Phylum) ◦Mammalia (Class) ◦Primates (Order) ◦Hominidae (Family) ◦Hominini (Tribe) ◦Homo (Genus) ◦Sapiens (Species) The parenthesized names are the names for that level of classification in biological taxonomy. 1/12/2015CS 2302-SPRING

Subclass Relationships All mammals (those in class mammalia) are also chordates (members of the phylum chordata) ◦Chordates have, among other features, a hollow dorsal nerve cord, at least at some stage of development ◦Mammals all have a hollow dorsal nerve cord, early in embryonic development ◦Mammals have other characteristics that are not shared by all chordates, such as three middle ear bones and mammary glands ◦There are chordates that are not mammals. For example, bony fish All primates (those in order primate) are also mammals (those in class mammalia) ◦Primates share all the characteristics that mammals have ◦Primates have other characteristics, not shared by non-primate mammals, such as nails instead of claws 1/12/2015CS 2302-SPRING

Remarks on Human Taxonomy We belong to various groups based on common anatomical characteristics We humans are mammals, along with bears, dogs, elephants and whales. ◦Hair, three middle ear bones, mammary glands We are primates, along with lemurs and monkeys ◦Forward facing eyes, keratin nails, domed cranium We are hominidae, along with chimpanzees and gorillas ◦Genetic similarities are the most recent basis for classification 1/12/2015CS 2302-SPRING

GeometricObject Example One important and flexible way to create pictures is as a composition of simple figures ◦One scheme, SVG, is used to create sophisticated images from simple components. ◦The clock is a nice example: The GeometricObject example in this chapter shows how inheritance can be used to organize a 'family' of related classes. This example will be elaborated upon in later chapters and, eventually, used to create actual pictures. 1/12/2015CS 2302-SPRING

Implementation Setup We will change the book example in a couple of ways ◦The example will use packages ◦Because the packages take care of 'name collision', the names of the classes will be simplified Create package cs2302sp15.chap11 Create the basic class files 1/12/2015CS 2302-SPRING

Analyzing Geometry Circles and rectangles make an easy first step Common characteristics of these two are ◦Color to use ◦Whether to fill in the figure or just an outline ◦The date on which the object was created Characteristics unique to the figures are ◦Circle ◦radius ◦Rectangle ◦height ◦width 1/12/2015CS 2302-SPRING

Design Three classes will be created in Java ◦ GeometricObject ◦ Rectangle ◦ Circle GeometricObject represents the common features of Rectangle and Circle The Rectangle and Circle classes represent the features specific to those shapes 1/12/2015CS 2302-SPRING

UML Diagram 12

UML Diagram Explained Each class is a rectangle ◦Name at the top ◦Instance variables in the middle ◦Instance methods at the bottom + indicates public, - indicates private The arrows with open triangular heads represent the inheritance relationships ◦All circles are geometric objects: the circle class is a subclass of the geometric object class ◦All rectangles are geometric objects: the rectangle class is a subclass of the geometric object class 1/12/2015CS 2302-SPRING

Other Terminology The circle class extends the geometric object class The geometric object class is a superclass of the circle class The geometric object class generalizes the circle class 1/12/2015CS 2302-SPRING

Representing Inheritance in Java The extends keyword indicates that the class being defined is a subclass of another class The name of the other class follows the keyword A class may extend only one other class If no explicit superclass is designated, then Object is the implicit superclass 1/12/2015CS 2302-SPRING public class Circle extends GeometricObject

Filling in the Classes Attributes ◦ GeometricObject : color, filled, dateCreated ◦ Circle : radius ◦ Rectangle : width, height Methods ◦Getters and setters (note isFilled rather than getFilled ) ◦Get area and perimeter in Circle and Rectangle ◦ printcircle ◦ toString in GeometricObject ◦Various constructors 1/12/2015CS 2302-SPRING

A Program We see that we can use the methods defined in GeometricObject in classes Circle and Rectangle Create a Circle, print some attributes Create a Rectangle, print some attributes 1/12/2015CS 2302-SPRING