1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
Private Class CPersonne
Private _Nom As String
Private _Prenom As String
Private _DateNaissance As Date
Private _Adresse As String
Public Sub New(ByVal Nom As String, ByVal Prenom As String, ByVal DateNaissance As Date, ByVal Adresse As String)
_Nom = Nom
_Prenom = Prenom
_DateNaissance = DateNaissance
_Adresse = Adresse
End Sub
End Class
Private Class CEtudiant
Inherits CPersonne
Private _notes As Single()
Public Sub New(ByVal Nom As String, ByVal Prenom As String, ByVal DateNaissance As Date, ByVal Adresse As String, ByVal Notes As Single())
MyBase.New(Nom, Prenom, DateNaissance, Adresse)
_notes = Notes
End Sub
Public ReadOnly Property Moyenne() As Single
Get
Dim sommeNotes As Single = 0
For Each note As Single In _notes
sommeNotes += note
Next
Return sommeNotes / _notes.Length
End Get
End Property
End Class
Private Sub TEST()
Dim personneTest As New CPersonne("Dupont", "Pierre", New Date(1970, 12, 25), "20 rue du Code")
Dim etudiantTest As New CEtudiant("Dupont", "Marie", New Date(1972, 8, 3), "20 rue du Code", New Single() {10.0, 18.0, 5.0})
Dim moyenneMarie As Single = etudiantTest.Moyenne
End Sub |