Implement an Interface : Interface « Class « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Class » InterfaceScreenshots 
Implement an Interface
Implement an Interface

Imports System
Imports System.Collections


Public Class MainClass

  Shared Sub Main()

    Dim e1 As New Programmer("E1"50000)
    Dim e2 As New Employee("E2"40000)
    
    Dim theTeam As Employee() {e1, e2}
    
    e1.MyTeam = theTeam
    
    Console.WriteLine(e1.Rate(e2))
    
  End Sub
End Class


Public Interface ILead
  Sub SpendMoraleFund(ByVal amount As Decimal)
  Function Rate(ByVal aPerson As EmployeeAs String
  Property MyTeam() As Employee()
  Property MoraleFund() As Decimal
End Interface

Public Class Programmer
  Inherits Employee
  Implements ILead
  Private m_MoraleFund As Decimal
  Private m_MyTeam As Employee()
  Public Function Rate(ByVal aPerson As EmployeeAs String _
  Implements ILead.Rate
    Return aPerson.TheName & " rating to be done"
  End Function
  Public Property MyTeam() As Employee() _
  Implements ILead.MyTeam
    Get
      Return m_MyTeam
    End Get
    Set(ByVal Value As Employee())
      m_MyTeam = Value
    End Set
  End Property
  Public Sub SpendMoraleFund(ByVal amount As Decimal_
  Implements ILead.SpendMoraleFund
    'spend some money
    Console.WriteLine("Spent " & amount.ToString())
  End Sub
  Public Property OurMoraleFund() As Decimal Implements ILead.MoraleFund
    Get
      Return m_MoraleFund
    End Get
    Set(ByVal Value As Decimal)
      m_MoraleFund = Value
    End Set
  End Property
  Public Sub New(ByVal theName As String, ByVal curSalary As Decimal)
    MyBase.New(theName, curSalary)
  End Sub
End Class

Public Class Employee
  Private m_Name As String
  Private m_Salary As Decimal

  Public Sub New(ByVal theName As String, ByVal curSalary As Decimal)
    m_Name = theName
    m_Salary = curSalary
  End Sub

  Public ReadOnly Property TheName() As String
    Get
      Return m_Name
    End Get
  End Property

  Public ReadOnly Property Salary() As Decimal
    Get
      Return MyClass.m_Salary
    End Get
  End Property

End Class


           
       
Related examples in the same category
1.One Class implements two Interfaces which have the same name methodOne Class implements two Interfaces which have the same name method
2.Interface inherits interfaceInterface inherits interface
3.Class implements two interfaces
4.Implements an InterfaceImplements an Interface
5.Define and use Interface AgeDefine and use Interface Age
6.Interface Inherits another InterfaceInterface Inherits another Interface
7.Define and use InterfaceDefine and use Interface
8.Implements Two InterfacesImplements Two Interfaces
9.Generic Class and InterfaceGeneric Class and Interface
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.