Chapter 11. Object-Oriented Programming: Polymorphism


One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.

J. R. R. Tolkien

General propositions do not decide concrete cases.

Oliver Wendell Holmes

A philosopher of imposing stature doesn't think in a vacuum. Even his most abstract ideas are, to some extent, conditioned by what is or is not known in the time when he lives.

Alfred North Whitehead

Why art thou cast down, O my soul?

Psalms 42:5

Objectives

In this chapter you will learn:

  • What polymorphism is.

  • To use overridden methods to effect polymorphism.

  • To distinguish between abstract and concrete classes.

  • To declare abstract methods to create abstract classes.

  • How polymorphism makes systems extensible and maintainable.

  • To determine an object's type at execution time.

  • To declare and implement interfaces.

Outline

11.1 Introduction

11.2 Polymorphic Video Game

11.3 Demonstrating Polymorphic Behavior

11.4 Abstract Classes and Methods

11.5 Case Study: Payroll System Class Hierarchy Using Polymorphism

11.5.1 Creating Abstract Base Class Employee

11.5.2 Creating Concrete Derived Class SalariedEmployee

11.5.3 Creating Concrete Derived Class HourlyEmployee

11.5.4 Creating Concrete Derived Class CommissionEmployee

11.5.5 Creating Indirect Concrete Derived Class BasePlusCommissionEmployee

11.5.6 Demonstrating Polymorphic Processing, Expression TypeOf...Is, TryCast and Downcasting

11.5.7 Summary of the Allowed Assignments between Base Class and Derived Class Variables

11.6 NotOverridable Methods and NotInheritable Classes

11.7 Case Study: Creating and Using Interfaces

11.7.1 Developing an IPayable Hierarchy

11.7.2 Declaring Interface IPayable

11.7.3 Creating Class Invoice

11.7.4 Modifying Class Employee to Implement Interface IPayable

11.7.5 Modifying Class SalariedEmployee for Use in the IPayable Hierarchy

11.7.6 Using Interface IPayable to Process Invoices and Employees Polymorphically

11.7.7 Common Interfaces of the .NET Framework Class Library (FCL)

11.8 (Optional) Software Engineering Case Study: Incorporating Inheritance and Polymorphism into the ATM System

11.9 Wrap-Up



Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net