Define Abstract Class and Reference Class by it : Abstract Class « Class « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net Tutorial
VB.Net » Class » Abstract ClassScreenshots 
Define Abstract Class and Reference Class by it
Define Abstract Class and Reference Class by it

Imports System

Public Class MainClass

  Shared Sub Main()
    Dim tom As New Employee("Tom"50000"111-11-1234")
    Dim sally As New Employee("Sally"150000"111-11-2234")

    Dim ourEmployees(1As PayableEntity
    ourEmployees(0= tom
    ourEmployees(1= sally
    Dim anEmployee As PayableEntity
    For Each anEmployee In ourEmployees
      Console.WriteLine(anEmployee.TheName & " has tax id " & anEmployee.TaxID )
    Next

  End Sub
End Class

Public MustInherit Class PayableEntity
  Private m_Name As String
  Public Sub New(ByVal itsName As String)
    m_Name = itsName
  End Sub
  ReadOnly Property TheName() As String
    Get
      Return m_Name
    End Get
  End Property
  Public MustOverride Property TaxID() As String
End Class

Public Class Employee
  Inherits PayableEntity
  Private m_Salary As Decimal
  Private m_TaxID As String
  Private Const LIMIT As Decimal = 0.1D
  Public Sub New(ByVal theName As String, ByVal curSalary As Decimal, ByVal TaxID As String)
    MyBase.New(theName)
    m_Salary = curSalary
    m_TaxID = TaxID
  End Sub
  Public Overrides Property TaxID() As String
    Get
      Return m_TaxID
    End Get
    Set(ByVal Value As String)
        m_TaxID = Value
    End Set
  End Property
  ReadOnly Property Salary() As Decimal
    Get
      Return MyClass.m_Salary
    End Get
  End Property
  Public Overridable Overloads Sub RaiseSalary(ByVal Percent As Decimal)
    If Percent > LIMIT Then
      'not allowed
      Console.WriteLine("Percent > LIMIT")
    Else
      m_Salary = (1D + Percent* m_Salary
    End If
  End Sub
  Public Overridable Overloads Sub RaiseSalary(ByVal Percent As _
  Decimal, ByVal Password As String)
    If Password = "special" Then
      m_Salary = (1D + Percent* m_Salary
    End If
  End Sub
End Class


           
       
Related examples in the same category
1. Abstract (MustInherit) Class Abstract (MustInherit) Class
w_w___w__._j___a___v_a___2_s___.___co_m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.