Tuesday, March 17, 2009

AlienShip Class Inheritance

Here's a solution for C# that demonstrates how to override a method with a new sub-class of alien ship and then iterate over the base class to access them all regardless of their place in the heirarchy.

We will discuss and implement this in the lecture today.

Why do you want this? So you can make a 1000 different types of aliens and then in 1 foreach loop access them all for drawing, updating etc, without messy switch statements.

This also addresses part of our studies to deal with arrays of user defined types. We will also look at debugging today.

AlienShip Class

No comments:

Post a Comment