Revised: Fri May 06 15:50:20 CDT 2016
This page is part of a Book titled XNA Game Studio .
Table of Contents
- Table of Contents
- Preface
- General background information
- Preview
- Discussion and sample code
- Run the program
- Run my program
- Summary
- Miscellaneous
- Complete program listing
Preface
This module is one in a collection of modules designed primarily for teaching GAME 1343 Game and Simulation Programming I at Austin Community College in Austin, TX. These modules are intended tosupplement and not to replace the textbook.
An earlier module titled Getting Started provided information on how to get started programming with Microsoft's XNA Game Studio.
Object-oriented programs exhibit three main characteristics:
- Encapsulation
- Inheritance
- Polymorphism
I have explained encapsulation, inheritance, and compile-time polymorphism in earlier modules. I will continue my explanation of polymorphism in this modulewith an explanation of runtime polymorphism using method overriding and class inheritance. I will defer an explanation of polymorphism using interfaceinheritance until a future module.
Viewing tip
I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the Listings while you are reading about them.
Listings
- Listing 1 . Class A.
- Listing 2 . Class B.
- Listing 3 . Beginning of the driver class.
- Listing 4 . This is runtime polymorphic behavior.
- Listing 5 . A failed attempt.
- Listing 6 . Not polymorphic behavior.
- Listing 7 . Project Polymorph03.
General background information
What is polymorphism?
As you learned in an earlier module, the meaning of the word polymorphism is something like one name, many forms .
How does C# implement polymorphism?
Also as you learned in an earlier module, polymorphism manifests itself in C# in the form of multiple methods having the same name.