Berikut akan saya berikan sedikit kode sebagai implementasi dari inheritance di vb.net...
' Membuat object mobil
Public Class Car
Public Color As String
Private numberOfDoors As Integer
' Konstruksi
Sub New()
' Setting menjadi default:
Color = "White"
numberOfDoors = 5
End Sub
Property NumberOfDoors() As Integer
'Memanggil ketika property "got"
Get
Return numberOfDoors
End Get
End Property
End Class
' Proses inheritance objek mobil
Public Class SportsCar
Inherits Car
Public Weight As Integer
End Class
' Module where the real instance of Car and SportsCar Object are Utilized.
'Modul dimana instansiasi dari objek mobil dan mobil sport dimanfaatkan
Module Module1
Sub Main()
' membuat objek mobil baru...
Dim myCar As SportsCar
myCar = New SportsCar()
' setting berat (kg)...
myCar.Weight = 1085
' laporan details...
Console.WriteLine("Weight:" & myCar.Weight)
' menunggu...
Console.ReadLine()
End Sub
End Module
Langganan:
Posting Komentar (Atom)
Grab this Widget ~ Blogger Accessories Custumized by Yuniarto Rahardjo
0 komentar:
Posting Komentar