Professional Documents
Culture Documents
Outline
In the previous lecture, we introduced Objects
And discussed the basics of Object-Oriented Programming…
Members, Methods, Properties, etc
Defining Objects: Classes
We also discussed Console Applications:
When to abandon a GUI-based Approach.
In favor of a command-line interface.
Our Example: The J_Train Class
We now continue our discussion of O.O. Programming:
Defining Constructors, which allow:
Convenient encapsulation of default characteristics.
Clients to create new Object instances with specified characteristics.
The concept of Inheritance
By which we may create ‘derived Classes’...
Which inherit and expand upon the characteristics of a Base Class
Our Example: The JFreightTrain Class
Which inherits from JTrain.
Constructors
Earlier, we created a single JTrain instance (JTrain001)…
And provided it with natural, default characteristics…
Based automatically on the initialized Member values (not very elegant).
We then set the desired characteristics of JTrain001 manually.
However, what if we wanted to create another JTrain instance…?
But, we want the new instance to start its life with different values…
More characteristics are then added, to quickly compose a more specific class.
This is accomplished in VB.NET using the keyword, Inherits.
Such a derived Class is said to Inherit from the original (base) Class.
Again, this is very similar to real-world objects…
Inheritance
Used to create ‘derived Classes’...
Which inherit the characteristics of a Base Class
Example: The JFreightTrain Class
We also discussed Overriding Base Class Constructors