Class Relationships A class defines a type of data Composition allows an object of another class to define an attribute of a class –Employee “has a”

Slides:



Advertisements
Similar presentations
2006 Pearson Education, Inc. All rights reserved Object-Oriented Programming: Polymorphism.
Advertisements

COP 3003 Object-Oriented Programming - Inheritance Dr. Janusz Zalewski, Fall 2013 Prepared by Dr Dahai Guo.
Programming With Java ICS 201 University Of Ha’il1 Chapter 8 Abstract Class.
 2005 Pearson Education, Inc. All rights reserved Object-Oriented Programming: Inheritance.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4- 1.
Abstract Classes. Lecture Objectives To learn about abstract classes To understand how to inherit abstract classes To understand how to override abstract.
Slides prepared by Rose Williams, Binghamton University Chapter 7 Inheritance.
Inheritance. In this chapter, we will cover: The concept of inheritance Extending classes Overriding superclass methods Working with superclasses that.
CS102--Object Oriented Programming Lecture 7: – Inheritance Copyright © 2008 Xiaoyan Li.
1 Evan Korth New York University abstract classes and casting Professor Evan Korth New York University.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Enhanced Entity-Relationship (EER) Modeling.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 17 – Payroll Application: Introducing Inheritance.
 2005 Pearson Education, Inc. All rights reserved Object-Oriented Programming: Polymorphism.
1 Enhanced Entity Relationship Modelling EER Model Concepts Includes all basic ER modeling concepts Additional concepts: subclasses/superclasses specialization/generalization.
Chapter 10: Inheritance 1. Inheritance  Inheritance allows a software developer to derive a new class from an existing one  The existing class is called.
Specialization and generalization
Enhanced Entity-Relationship Model (EER) 1. Enhanced-ER (EER) Model Concepts Includes all modeling concepts of basic ER Additional concepts: subclasses/superclasses,
Object Oriented Programming: Inheritance Chapter 9.
Object Oriented Programming using Java - Polymorphism
 Simple payroll application that polymorphically calculates the weekly pay of several different types of employees using each employee’s Earnings method.
 2005 Pearson Education, Inc. All rights reserved Object-Oriented Programming: Inheritance.
Object Oriented Concepts
CISC6795: Spring Object-Oriented Programming: Polymorphism.
Object Oriented Concepts Classes II. Object Oriented concepts Encapsulation Composition Inheritance Polymorphism.
1 CSE 480: Database Systems Lecture 4: Enhanced Entity-Relationship Modeling Reference: Read Chapter 8.1 – 8.5 of the textbook.
Method signature Name and parameter list public static void test() public static int test() => Syntax error, Duplicate method test You cannot declare more.
Mark Fontenot CSE Honors Principles of Computer Science I Note Set 14.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
More on Object-Oriented Programming: Inheritance 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
© Shamkant B. Navathe CC. © Shamkant B. Navathe CC Chapter 4 - Part I Enhanced Entity-Relationship and UML Modeling Copyright © 2004 Ramez Elmasri and.
GOALS BUSINESS MATH© Thomson/South-WesternLesson 1.1Slide 1 1.1Hourly Pay and Salary Calculate gross pay for hourly-rate employees Calculate gross pay.
Object Oriented Software Development
Enhanced Entity-Relationship (EER) Modeling. Slide 4- 2 Chapter Outline EER stands for Enhanced ER or Extended ER EER Model Concepts Includes all modeling.
Java Programming Dr. Randy Kaplan. Abstract Classes and Methods.
O O P Polymorphism Object Oriented Programming Prepared & Presented by: dr.Ismail Farahat Chapter 4.
1 The finalize, clone, and getClass Methods  The finalize method is invoked by the garbage collector on an object when the object becomes garbage.  The.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4- 1.
Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Ramez Elmasri and Shamkant Navathe Enhanced-ER (EER) Model Concepts.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Enhanced Entity-Relationship (EER) Modeling.
 Pearson Education, Inc. All rights reserved Object-Oriented Programming: Polymorphism.
© Shamkant B. Navathe CC Enhanced Entity-Relationship Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
CET203 SOFTWARE DEVELOPMENT Session 2A Inheritance (programming in C#)
Inheritance ndex.html ndex.htmland “Java.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Object Oriented Programming: Inheritance Chapter 9.
C++ How to Program, 7/e.  There are cases in which it’s useful to define classes from which you never intend to instantiate any objects.  Such classes.
Object-Oriented Programming: Polymorphism
Chapter 12 OOP: Polymorphism, Interfaces and Operator Overloading
The Enhanced Entity- Relationship (EER) Model
Enhanced Entity-Relationship (EER) Modeling
Session 2 Welcome: The sixth learning sequence
Python First Edition STARTING OUT WITH Chapter 10 Inheritance
Object-Oriented Programming: Inheritance
abstract classes and casting objects
Object-Oriented Programming: Polymorphism
“Java - How to Program” (6th) by Deitel & Deitel
Object-Oriented Programming: Polymorphism
Chapter 9 Object-Oriented Programming: Inheritance
Object Oriented Programming: Inheritance
LESSON 12-1 Preparing Payroll Time Cards
ANALYZING A PAYROLL TIME CARD
CS4222 Principles of Database System
Law firm employee analogy
Sampath Jayarathna Cal Poly Pomona
Object-Oriented Programming: Polymorphism
LESSON 12-1 Preparing Payroll Time Cards
LESSON 12-1 Preparing Payroll Time Cards
Chapter 7 Inheritance.
ANALYZING A PAYROLL TIME CARD
Presentation transcript:

Class Relationships A class defines a type of data Composition allows an object of another class to define an attribute of a class –Employee “has a” Date Inheritance allows more specific versions (subclasses) of a class to be defined –SalariedEmployee “is a” Employee –A subclass can “extend” only one class (single inheritance)

Employee-Payroll Example Look at pages in textbook One superclass: –Employee Three subclasses of Employee: –SalariedEmployee –CommissionEmployee –HourlyEmployee One subclass of CommissionEmployee: –BasePlusCommissionEmployee

How could we add Composition? Date? Currency? What else?

How do we know when we need a subclass??? Superclass: –General case –What ALL employees have (attributes) or do (methods) Subclass: –More specific case –What particular types of employees have (attributes) or do (methods)

What about polymorphism??? Superclass: – defines what ALL employees do – earn money! Subclass: – define specific ways this is calculated –SalariedEmployees get fixed earnings –HourlyEmployees get paid by the hour –CommissionEmployees’ earnings include a commission BasePlusCommissionEmployees are a more specific type of CommissionEmployee – they earn a base salary plus commission

Class Diagram Create a class diagram to show the class relationships of the Employee-Payroll class hierarchy. Include two additional composition classes.