Uroci.net - !
Adobe Photoshop Adobe Illustrator Adobe Flash Adobe Fireworks DreamWeaver CSS HTML Corel Draw Image Ready PHP SEO CMS Microsoft Windows Microsoft Word Microsoft Excel PowerPoint Microsoft Access Microsoft Publisher Linux Visual basic
JavaScript Ajax 3ds Max Maya 3D C++ Sound Forge Gimp SWiSH

(Inheritance)

bubust   :    : 1661

- VB .NET . . , (Slujasht) Slujasht CSlujasht --name, address, Zaplata ..

. CDirector CSecretary, . , (Slujasht), . !

. , CSlujasht, Zaplata IncZaplata:

' Slujasht class

Public Class CSlujasht

' Zaplata property read/write

Private mdecZaplata As Decimal

Property Zaplata( ) As Decimal

Get

Zaplata = mdecZaplata

End Get

Set

mdecZaplata = Value

End Set

End Property

Public Overridable Sub IncZaplata(ByVal sngPercent As Single)

mdecZaplata = mdecZaplata * (1 + CDec(sngPercent))

End Sub

End Class

CDirector:

' Director Class

Public Class CDirector

Inherits CSlujasht

' Calculate Zaplata 5%

Overrides Sub IncZaplata(ByVal sngPercent As Single)

Me.Zaplata = Me.Zaplata * CDec(1.05 + sngPercent)

End Sub

End Class



. :

Inherits CSlujasht

, CDirector (inherits) CSlujasht. CDirector CSlujasht. CDirector:

Dim ceo As New CDirector

Zaplata, :

ceo.Zaplata = 1000

, Overrides IncZaplata , IncZaplata CDirector CSlujasht. :

ceo.IncZaplata

CDirector ceo . Overridable IncZaplata CSlujasht, , - override .

, CSecretary, CSlujasht :

' Secretary Class -

Public Class CSecretary

Inherits CSlujasht

' 2%

Overrides Sub IncZaplata(ByVal sngPercent As Single)

Me.Zaplata = Me.Zaplata * CDec(1.02 + sngPercent)

End Sub

End Class

:

Dim ThePrincipal As New CDirector( )

Dim MySecretary As New CSecretary( )

' Set

ThePrincipal.Zaplata = 1000

MySecretary.Zaplata = 300

' Set Slujasht - Principal incZaplata

Debug.Writeline("Principal before: " & CStr(ThePrincipal.Zaplata))

ThePrincipal.IncZaplata(0.4)

Debug.WriteLine("Principal after: " & CStr(ThePrincipal.Zaplata))

' Set Slujasht - Principal inc Zaplata

Debug.Writeline("Principal before: " & CStr(ThePrincipal.Zaplata))

ThePrincipal.IncZaplata(0.4)

Debug.WriteLine("Principal after: " & CStr(ThePrincipal.Zaplata))

' Set Slujasht - Secretary inc Zaplata

Debug.Writeline("Secretary before: " & CStr(MySecretary.Zaplata))

MySecretary.IncZaplata(0.4)

Debug.WriteLine("Secretary after: " & CStr(MySecretary.Zaplata))



:

Principal before: 1000

Principal after: 1450

Secretary before: 300

Secretary after: 396

:

B A, B A (public) ( ) A. , A (base class), B (derived class). , (override) .

Inherits.

, () - ( - base class).

(derived class) (fields), (properties), (methods) (overriding). , (inherited class).



: 1 2 »

,


© . 2006-2008. Created by: Site.bg
: IT | | . | Paparak.bg | | uchenik.com | TRAVEL | | AmAm.bg | . | | AnimeS-bg.com | | | | IT Light | Spodeli.net | - | IDG.BG | Teenproblem.net | - | Fresh-BG.com | Hanovete.com | Bulfleet.com | Mythlands.com | Ohoboho.com | .Com | News24 | Setcom.bg | Atol.bg | Elmaz.com | MobileBulgaria.com