The instance of the class AJAXBook.
SUV contains the method get_DriveType, but the get_MakeandModel and get_Year
methods are implemented by the base class AJAXBook.Car and inherited by the derived
class AJAXBook.SUV. Run the application, and you??™ll see them in action (see Figure 3-11).
Figure 3-11. Calling a method from the base class on the derived class
Implementing Interfaces in JavaScript
The AJAX Library also adds support for interfaces to JavaScript. An interface is a contract
??”by implementing an interface, you state that you will implement a specific set of
methods. Using interfaces allows you to implement a common set of methods across
multiple classes with less room for error (e.g., leaving a method out in one of the classes).
CHAPTER 3 ?– THE MICROSOFT AJAX LIBRARY: MAKING CLIENT-SIDE JAVASCRIPT EASIER 45
As an example, consider the following case. There are two types of sports cars: a ???real???
sports car that has a stick shift (manual transmission) and an ???imitation??? sports car that
has an automatic transmission.
Here is the code that defines the stick shift interface:
AJAXBook.
Pages:
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98