Site hosted by Angelfire.com: Build your free website today!

Base Class
Home ] Up ] [ Base Class ] Subclass ]

 

'Class Name:    BookSale
'Programmer:    Stephen DeVoy
'Date:          Today's Date
'Descritpion:   Handle books sale information.
'Folder:        CH06BS

Public Class BookSale

#Region "Properties"

    Protected Shared mdecSalesTotal As Decimal
    Protected Shared mintSalesCount As Integer

    Protected mstrTitle As String
    Protected mintQuantity As Integer
    Protected mdecPrice As Decimal

    Shared ReadOnly Property SalesTotal() As Decimal
        Get
            SalesTotal = mdecSalesTotal
        End Get
    End Property

    Shared ReadOnly Property SalesCount() As Integer
        Get
            SalesCount = mintSalesCount
        End Get
    End Property

    Property Title() As String
        Get
            Title = mstrTitle
        End Get
        Set(ByVal Value As String)
            mstrTitle = Value
        End Set
    End Property

    Property Quantity() As String
        Get
            Quantity = mintQuantity
        End Get
        Set(ByVal Value As String)
            If Value >= 0 Then
                mintQuantity = Value
            End If
        End Set
    End Property

    Property Price() As Decimal
        Get
            Price = mdecPrice
        End Get
        Set(ByVal Value As Decimal)
            If Value >= 0 Then
                mdecPrice = Value
            End If
        End Set
    End Property

#End Region

#Region "Methods"

    Sub New()
        'Empty argument list to create a new object
    End Sub

    Sub New(ByVal Title As String, ByVal Quantity As Integer, _
    ByVal Price As Decimal)
        'Assign property values

        Me.Title = Title
        Me.Quantity = Quantity
        Me.Price = Price
    End Sub

    Public Overridable Function ExtendedPrice() As Decimal
        'Calculate the extended price
        Dim decExtendedPrice As Decimal

        decExtendedPrice = mintQuantity * mdecPrice
        mdecSalesTotal += decExtendedPrice
        mintSalesCount += 1
        Return decExtendedPrice
    End Function

#End Region

End Class