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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
Public Interface IOperator
ReadOnly Property A() As Decimal
ReadOnly Property B() As Decimal
ReadOnly Property C() As Decimal
End Interface
Public Interface ISurface
Inherits IOperator
ReadOnly Property Total() As Decimal
End Interface
Public MustInherit Class [Operator]
Implements IOperator
Private _operande As ISurface
Public ReadOnly Property Operande() As ISurface
Get
Return Me._operande
End Get
End Property
Public ReadOnly Property A() As Decimal Implements IOperator.A
Get
Return Compute(_operande.A)
End Get
End Property
Public ReadOnly Property B() As Decimal Implements IOperator.B
Get
Return Compute(_operande.B)
End Get
End Property
Public ReadOnly Property C() As Decimal Implements IOperator.C
Get
Return Compute(_operande.C)
End Get
End Property
Public Sub New(operande As ISurface)
Me._operande = operande
End Sub
Public MustOverride Function Compute(value As Decimal) As Decimal
End Class
Public Class Pourcent
Inherits [Operator]
Public Sub New(operande As ISurface)
MyBase.New(operande)
End Sub
Public Overrides Function Compute(value As Decimal) As Decimal
Return If(Operande.Total = 0, 0, value * 100 / Operande.Total)
End Function
End Class
Public Class PourcentWithoutA
Inherits [Operator]
Public ReadOnly Property TotalWithoutA() As Decimal
Get
Return Me.Operande.B + Me.Operande.C
End Get
End Property
Public Sub New(operande As ISurface)
MyBase.New(operande)
End Sub
Public Overrides Function Compute(value As Decimal) As Decimal
Return If(Me.TotalWithoutA = 0, 0, (value * 100) / Me.TotalWithoutA)
End Function
End Class
Public Class Surface
Implements ISurface
Private _a As Decimal
Private _b As Decimal
Private _c As Decimal
Private ReadOnly _pourcentage As Pourcent
Private ReadOnly _pourcentageSansA As PourcentWithoutA
Public Property A() As Decimal Implements IOperator.A
Get
Return _a
End Get
Set
_a = Value
End Set
End Property
Public Property B() As Decimal Implements IOperator.B
Get
Return _b
End Get
Set
_b = Value
End Set
End Property
Public Property C() As Decimal Implements IOperator.C
Get
Return _c
End Get
Set
_c = Value
End Set
End Property
Public ReadOnly Property Pourcentage() As Pourcent
Get
Return Me._pourcentage
End Get
End Property
Public ReadOnly Property PourcentageSansA() As PourcentWithoutA
Get
Return Me._pourcentageSansA
End Get
End Property
Public ReadOnly Property Total() As Decimal Implements ISurface.Total
Get
Return Me.A + Me.B + Me.C
End Get
End Property
Public Sub New()
_a = 0
_b = 0
_c = 0
Me._pourcentage = New Pourcent(Me)
Me._pourcentageSansA = New PourcentWithoutA(Me)
End Sub
Public Sub New(a As Decimal, b As Decimal, c As Decimal)
Me.New()
Me._a = a
Me._b = b
Me._c = c
End Sub
End Class |