| | |
more about my arrayList
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2005
Posts: 7
Reputation:
Solved Threads: 0
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!
and again thank you for any input &/or advice.... Cindy :o
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!
VB.NET Syntax (Toggle Plain Text)
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
VB.NET Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- Using operator[] with an ArrayList (Java)
- removing duplicates in arraylist (Java)
- Is ArrayList Better than Vector (Java)
- Storing Point2D.Double objects in an ArrayList. (Java)
- Need Help with ArrayList sorting (Java)
Other Threads in the VB.NET Forum
- Previous Thread: Help,Fibonacci numbers
- Next Thread: How to: Resize MDI container on a form
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array arrays basic bing button buttons c# center check checkbox code combobox convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog filter ftp generatetags google gridview hardcopy images inline input insert intel internet listview mobile monitor ms net networking objects output panel passingparameters picturebox picturebox1 port position print printing problem project read remove save searchbox searchvb.net select serial server shutdown soap sorting survey table tcp temperature text textbox timer timespan toolbox trim update user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio2008 web winforms wpf year





