cindynicole 0 Newbie Poster

Ok, I will try to explain what i'm doing and hopefully post it correctly....
I have a few classes: Product(abstract), Pizza, drink, salad, and special.... Special being the class with the arraylist, i want to add a pizza object, drink object, and salad object (creating a user meal deal if you will).....

my tester class!

Imports System.Collections
Module ThePizzaEmporium
    Sub Main()

        Dim myspecial As ArrayList = New ArrayList


        ''sizes:  s = small, m = medium, l = large, slice = slice
        Dim myPizza As New pizza
        myPizza.mSize = "slice"
        myPizza.pizzaTopping = 2
        ' myPizza.calculateFee()

        Console.WriteLine(myPizza.TellAboutSelf)

        Dim shirt As New nonFoodProduct
        shirt.mSize = "s"
        shirt.Color = "pink"
        'shirt.calculateFee()

        Console.WriteLine(shirt.TellAboutSelf)

        Dim mySoda As New drinks
        mySoda.drinkType = "diet pepsi"
        mySoda.Size = "l"
        'mySoda.calculateFee()

        Console.WriteLine(mySoda.TellAboutSelf)



        Dim mySalad As New salad
        'mySalad.saladType = "salad bar"
        mySalad.Size = "single"
        'mySalad.calculateFee()

        Console.WriteLine(mySalad.TellAboutSelf)


        ''I DON'T KNOW WHAT TO DO W/THE ARRAYLIST OR HOW TO PUT ITEMS IN IT

        Dim dealItem1 As New pizza
        dealItem1.pizzaTopping = 1
        dealItem1.mSize = "slice"

        Dim dealItem2 As New drinks
        dealItem2.mSize = "l"
        dealItem2.drinkType = "diet pepsi"

        myspecial.Add(dealItem1)
        myspecial.Add(dealItem2)




        myspecial.Add(myPizza)
        myspecial.Add(mySalad)
        myspecial.Add(mySoda)

        For i As Integer = 0 To 4
            Console.WriteLine(myspecial.Item(i).tellaboutself)

        Next



        For i As Integer = 1 To 5
            ''IT DOESN'T LIKE THIS CTYPE 
            Dim currentMeal As special = CType(myspecial.Item(i), special) ' as special



            currentMeal.AddToSpecialMealDeal(myspecial.Item(i))
            currentMeal.calculateFee()
            currentMeal.TellAboutSelf()
            Console.WriteLine(currentMeal.TellAboutSelf())

        Next
       

    End Sub

End Module
Imports System.Collections
Public Class special
    Inherits Product

    ''array to hold individual objects of a special meal deal
    Public mSpecialMeal As ArrayList = New ArrayList
    ''adding product item (drink, pizza slice, single salad) to arraylist
    Public Sub AddToSpecialMealDeal(ByVal Product As System.Object)

        Dim newItem As special = CType(Product, special)
        mSpecialMeal.Add(newItem)


    End Sub
    Public ReadOnly Property MealDeal()
        Get
            Return mSpecialMeal

        End Get
    End Property

    Public Overrides Function TellAboutSelf() As String
        ''want to return specific items in the specfic special order or meal deal
        Dim mealDealInfo As String = ""
        For i As Integer = 0 To mSpecialMeal.Count - 1
            Dim current As special = CType(mSpecialMeal.Item(i), special)
            mealDealInfo &= current.TellAboutSelf
        Next
        Return mealDealInfo



    End Function

    Public Overrides Function calculateFee() As Double

        Dim mealDealPrice As Double = 0
        For i As Integer = 0 To mSpecialMeal.Count - 1
            Dim current As special = CType(mSpecialMeal.Item(i), special)
            mealDealPrice += current.Price

        Next
        Return mealDealPrice

    End Function


End Class

and again thank you for any input &/or advice.... Cindy :o

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.