more about my arrayList

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2005
Posts: 7
Reputation: cindynicole is an unknown quantity at this point 
Solved Threads: 0
cindynicole cindynicole is offline Offline
Newbie Poster

more about my arrayList

 
0
  #1
Dec 3rd, 2005
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!
  1. Imports System.Collections
  2. Module ThePizzaEmporium
  3. Sub Main()
  4.  
  5. Dim myspecial As ArrayList = New ArrayList
  6.  
  7.  
  8. ''sizes: s = small, m = medium, l = large, slice = slice
  9. Dim myPizza As New pizza
  10. myPizza.mSize = "slice"
  11. myPizza.pizzaTopping = 2
  12. ' myPizza.calculateFee()
  13.  
  14. Console.WriteLine(myPizza.TellAboutSelf)
  15.  
  16. Dim shirt As New nonFoodProduct
  17. shirt.mSize = "s"
  18. shirt.Color = "pink"
  19. 'shirt.calculateFee()
  20.  
  21. Console.WriteLine(shirt.TellAboutSelf)
  22.  
  23. Dim mySoda As New drinks
  24. mySoda.drinkType = "diet pepsi"
  25. mySoda.Size = "l"
  26. 'mySoda.calculateFee()
  27.  
  28. Console.WriteLine(mySoda.TellAboutSelf)
  29.  
  30.  
  31.  
  32. Dim mySalad As New salad
  33. 'mySalad.saladType = "salad bar"
  34. mySalad.Size = "single"
  35. 'mySalad.calculateFee()
  36.  
  37. Console.WriteLine(mySalad.TellAboutSelf)
  38.  
  39.  
  40. ''I DON'T KNOW WHAT TO DO W/THE ARRAYLIST OR HOW TO PUT ITEMS IN IT
  41.  
  42. Dim dealItem1 As New pizza
  43. dealItem1.pizzaTopping = 1
  44. dealItem1.mSize = "slice"
  45.  
  46. Dim dealItem2 As New drinks
  47. dealItem2.mSize = "l"
  48. dealItem2.drinkType = "diet pepsi"
  49.  
  50. myspecial.Add(dealItem1)
  51. myspecial.Add(dealItem2)
  52.  
  53.  
  54.  
  55.  
  56. myspecial.Add(myPizza)
  57. myspecial.Add(mySalad)
  58. myspecial.Add(mySoda)
  59.  
  60. For i As Integer = 0 To 4
  61. Console.WriteLine(myspecial.Item(i).tellaboutself)
  62.  
  63. Next
  64.  
  65.  
  66.  
  67. For i As Integer = 1 To 5
  68. ''IT DOESN'T LIKE THIS CTYPE
  69. Dim currentMeal As special = CType(myspecial.Item(i), special) ' as special
  70.  
  71.  
  72.  
  73. currentMeal.AddToSpecialMealDeal(myspecial.Item(i))
  74. currentMeal.calculateFee()
  75. currentMeal.TellAboutSelf()
  76. Console.WriteLine(currentMeal.TellAboutSelf())
  77.  
  78. Next
  79.  
  80.  
  81. End Sub
  82.  
  83. End Module

  1. Imports System.Collections
  2. Public Class special
  3. Inherits Product
  4.  
  5. ''array to hold individual objects of a special meal deal
  6. Public mSpecialMeal As ArrayList = New ArrayList
  7. ''adding product item (drink, pizza slice, single salad) to arraylist
  8. Public Sub AddToSpecialMealDeal(ByVal Product As System.Object)
  9.  
  10. Dim newItem As special = CType(Product, special)
  11. mSpecialMeal.Add(newItem)
  12.  
  13.  
  14. End Sub
  15. Public ReadOnly Property MealDeal()
  16. Get
  17. Return mSpecialMeal
  18.  
  19. End Get
  20. End Property
  21.  
  22. Public Overrides Function TellAboutSelf() As String
  23. ''want to return specific items in the specfic special order or meal deal
  24. Dim mealDealInfo As String = ""
  25. For i As Integer = 0 To mSpecialMeal.Count - 1
  26. Dim current As special = CType(mSpecialMeal.Item(i), special)
  27. mealDealInfo &= current.TellAboutSelf
  28. Next
  29. Return mealDealInfo
  30.  
  31.  
  32.  
  33. End Function
  34.  
  35. Public Overrides Function calculateFee() As Double
  36.  
  37. Dim mealDealPrice As Double = 0
  38. For i As Integer = 0 To mSpecialMeal.Count - 1
  39. Dim current As special = CType(mSpecialMeal.Item(i), special)
  40. mealDealPrice += current.Price
  41.  
  42. Next
  43. Return mealDealPrice
  44.  
  45. End Function
  46.  
  47.  
  48. End Class

and again thank you for any input &/or advice.... Cindy :o
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC