Class Orders VB.Net Exercise - Visual Basic Programming Course


 Exercise

Class Orders

Objetive

Using Visual Studio, create a project and the corresponding classes (using several files) for this classes diagram.

Each class must include the attributes and methods shown in the diagram. Consider that all cardinalities are 1:1.

Code

Imports System
Namespace Orders
    Class Customer
        Public Sub New()
            name = ""
            address = ""
        End Sub

        Protected name As String
        Protected address As String
        Protected o As Order()
    End Class
End Namespace

Namespace Orders
    Class Item
        Inherits OrderDetail

        Public Sub New()
            shippingWeight = ""
            description = ""
        End Sub

        Protected shippingWeight As String
        Protected description As String

        Public Function getPriceForQuantity() As Double
            Return 0
        End Function

        Public Function getWeight() As Double
            Return 0
        End Function

        Public Function GetShippingWeight() As String
            Return shippingWeight
        End Function

        Public Function GetDescription() As String
            Return description
        End Function

        Public Sub SetShippingWeight(ByVal shippingWeight As String)
            Me.shippingWeight = shippingWeight
        End Sub

        Public Sub SetDescription(ByVal description As String)
            Me.description = description
        End Sub
    End Class
End Namespace

Namespace Orders
    Class Order
        Public Sub New()
            status = ""
        End Sub

        Protected date As DateTime
        Protected status As String
        Protected o As OrderDetail()

        Public Function calcTax() As Double
            Return 0
        End Function

        Public Function calcTotal() As Double
            Return 0
        End Function

        Public Function calcTotalWeight() As Double
            Return 0
        End Function

        Public Function GetDate() As DateTime
            Return date
        End Function

        Public Function GetStatus() As String
            Return status
        End Function

        Public Sub SetDate(ByVal date As DateTime)
            Me.date = date
        End Sub

        Public Sub SetStatus(ByVal status As String)
            Me.status = status
        End Sub
    End Class
End Namespace

Namespace Orders
    Class OrderDetail
        Public Sub New()
            quantity = 0.0
            taxStatus = ""
        End Sub

        Protected i As Item()
        Protected quantity As Double
        Protected taxStatus As String

        Public Function calcSubTotal() As Double
            Return 0
        End Function

        Public Function calcWeight() As Double
            Return 0
        End Function
    End Class
End Namespace


Juan A. Ripoll - Systems Tutorials and Programming Courses © 2024 All rights reserved.  Legal Conditions.