IS437: Fall 2004 Instructor: Dr. Boris Jukic

Slides:



Advertisements
Similar presentations
Chapter 5 Inheritance. Objectives Introduction, effects, and benefits of inheritance Base class and derived class objects Base class and derived class.
Advertisements

Inheritance. Many objects have a hierarchical relationship –Examples: zoo, car/vehicle, card game, airline reservation system Inheritance allows software.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
Classes and SubClasses Super Parent Sub Child IS - A.
CIS162AD Inheritance 09_inheritance.ppt. CIS162AD2 Overview of Topics  Inheritance  Virtual Methods used for Overriding  Constructors & Inheritance.
Chapter 11: Implementing Inheritance and Association Visual Basic.NET Programming: From Problem Analysis to Program Design.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
12-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
More about classes and objects Classes in Visual Basic.NET.
Chapter 6 OOP: Creating Object-Oriented Programs Programming In Visual Basic.NET.
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
VB Classes ISYS 573. Object-Oriented Concepts Abstraction: –To create a model of an object, for the purpose of determining the characteristics (properties)
VB Classes ISYS 512. Adding a Class to a Project Project/Add Class –*** MyClass is a VB keyword. Steps: –Adding properties Declare Public variables in.
Object-Oriented Programming: Inheritance Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Object-Oriented Programming: Inheritance
Inheritance Chapter 14. What is inheritance?  The ability to create a class from another class, the “parent” class, extending the functionality and state.
Inheritance using Java
110-I 1 Object Terminology Review Object - like a noun, a thing –Buttons, Text Boxes, Labels Properties - like an adjective, characteristics of object.
Module 7: Object-Oriented Programming in Visual Basic .NET
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
 2002 Prentice Hall. All rights reserved. 1 Chapter 9 – Object-Oriented Programming: Inheritance Outline 9.1Introduction 9.2 Base Classes and Derived.
Chapter 6 OOP: Creating Object-Oriented Programs Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Inheritance Building one object from another. Background Object-oriented programming is normally described has offering three capabilities Encapsulation:
CSCI 3327 Visual Basic Chapter 3: Classes and Objects UTPA – Fall 2011.
1 Working with Objects. 2 Defining a Class in VB.NET A class is a user-defined data type You can declare it as part of a module, but usually in a separate.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
CIS162AD Inheritance Part 3 09_inheritance.ppt. CIS162AD2 Overview of Topics  Inheritance  Virtual Methods used for Overriding  Abstract Classes and.
VB Classes ISYS 512/812. Object-Oriented Concepts Abstraction: –To create a model of an object, for the purpose of determining the characteristics (properties)
Inheritance Objectives: Creating new classes from existing classes The protected modifier Creating class hierarchies Abstract classes Indirect visibility.
© 2007 Lawrenceville Press Slide 1 Chapter 9 Inheritance  One class is an extension of another.  Allows a class to define a specialized type of an existing.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Chapter 2 11/18/2015 © by Pearson Education, Inc. All Rights Reserved. Lect9 GC 2011.
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
Object-Oriented Programming: Classes and Objects Chapter 1 1.
1 Inheritance One of the goals of object oriented programming is code reuse. Inheritance is one mechanism for accomplishing code reuse. It allows us to.
Object-Oriented Programming: Classes and Objects.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
These materials where developed by Martin Schray
Advanced Programming in Java
Modern Programming Tools And Techniques-I
Advanced Programming in Java
Advanced Programming in Java
Object-Oriented Programming: Classes and Objects
Inheritance and Polymorphism
Microsoft Visual Basic 2005: Reloaded Second Edition
An Introduction to Inheritance
Object-Oriented Programming: Classes and Objects
Object-Oriented Programming: Inheritance
Object-Oriented Programming: Inheritance
Chapter 11 – Object-Oriented Programming
Web Systems Development (CSC-215)
The super Reference Constructors cannot be used in child classes, even though they have public visibility Yet we often want to use the parent's constructor.
Advanced Programming Behnam Hatami Fall 2017.
METHOD OVERRIDING in JAVA
Chapter 11 Inheritance and Polymorphism
Java Programming, Second Edition
Object-Oriented Programming: Inheritance
Advanced Programming in Java
Object-Oriented Programming: Classes and Objects
Object-Oriented Programming: Inheritance and Polymorphism
Object-Oriented Programming: Inheritance
Fundaments of Game Design
CIS16 Application Development and Programming using Visual Basic.net
CIS 199 Final Review.
Classes & Objects A deeper Look Chapter 10 & 11
Eighth step for Learning C++ Programming
Object-Oriented Programming: Inheritance
Presentation transcript:

IS437: Fall 2004 Instructor: Dr. Boris Jukic Building Business Objects: Part 2

Inheritance Creating a new class, based on existing class All non-private members (elements) are inherited in the new , derived class In addition, all methods can be inherited (public or private) Public Class StudentBookSale Inherits BookSale

Inheritance: Constructor Sub New(ByVal Title As String, ByVal Quantity As Integer, ByVal Price As Decimal) MyBase.New(Title, Quantity, Price) CalculateStudentTotals() End Sub Base class constructor A new method, specific to the subclass only Derived subclass does not explicitly inherit the parent’s class constructor method It needs its own, within it can call the base class constructor Additional methods can be specified in the constructor class of the derived class

Inheritance: Polymorphism through Overriding Methods Protected Overrides Sub CalculateItemPrices() … End Sub Method as defined in derived class Protected Overridable Sub CalculateItemPrices() … End Sub Method as defined in base class Derived subclass can implement a method from the base (parent) class in a different way The method as described in the derived class overrides the method as defined in the base class when an instance of the inherited class is instantiated and used

Inheritance: Overriding Methods Protected Overrides Sub CalculateItemPrices() ExtendedPrice = Quantity * Price Discount = ExtendedPrice * STUDENT_DISCOUNT_RATE DiscountedPrice = ExtendedPrice - Discount End Sub Base class properties are used in calculations, but not base class private variables The method as defined in the derived (child) class can access the values of the properties defined in the base class The methods in children class do not have access to the private variables of the parent class

Inheritance: New Methods and Properties in Derived Class Private Shared decimalTotalStudentDiscount As Decimal Property TotalStudentDiscount() As Decimal Get Return decimalTotalStudentDiscount End Get Set(ByVal Value As Decimal) decimalTotalStudentDiscount = Value End Set End Property Private Sub CalculateStudentTotals() decimalTotalStudentDiscount += Discount End Sub Derived classes can have their own original (non-inherited methods and properties The values of those original properties are contained in the private variables defined in the inherited class module