// APS101, Winter 2009: Lecture 37 (Apr. 9) // // Review: last time we learned about, and implemented, the binary search algorithm. // During the next two lectures we'll be discussing // Object Oriented (OO) Concepts in more detail. // Specifically, we'll be talking about Inheritance, // as well as 3 different types of Polymorphism: 1) method overloading 2) method overriding 3) dynamic method binding *** since we had technical difficulties today in lecture, we didn't cover as much of this material as we needed to. Please read the following notes carefully, in preparation for Monday's lecture *** /* Recall: Inheritance is the capability of a class to use the properties and methods of another class while adding its own functionality. An example would be a Car class: You could create a generic Car class with states and actions that are common to all Cars. Then, more specific classes could be defined for special cars, such as: Sports cars, 4WD, SUV, etc. The generic class is known as the parent (or superclass or base class) and the specific classes as children (or subclasses or derived classes). The concept of inheritance greatly enhances the ability to reuse code, as well as making design a much simpler and cleaner process. */ /* Method Overloading: Using the same method name but different signature (number, type, and order of parameters) (however, the return type must be the same!) */ /* Method Overriding: Using the exact same method signature (name, number of parameters and parameter types). When extending a class constructor, you can reuse the superclass constructor and overridden superclass methods by using the reserved word "super". e.g. super(x,y) which calls the superclass constructor or super.m(a,b) which calls method m in the superclass */ /* Polymorphism is the capability of an action or method to do different things based on the object that it is acting upon. This is a basic principle of Object Oriented programming. Overloading and overriding are two types of polymorphism. We will soon examine a third type: "dynamic method binding". */ *** take a look at classes Student, StudentAthlete, and StudentNerd. We will be working with these in Monday's lecture ***