please help me

JTDancer48

New member
Joined
May 4, 2005
Messages
3
Programming Experience
Beginner
Hello! I am trying to write an application that allows you to check certain boxes (ingrediants) and then click submit for it to search what recipes are available to you with the ingrediants you have. I am making it for a class and I chose to do this but I am lost. I have only been programming for a couple months and the professor is not very clear. Thanks!
 

JTDancer48

New member
Joined
May 4, 2005
Messages
3
Programming Experience
Beginner
i don't. My professor reccomended arrays. but i thought that a database might be easier. What do you think?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,321
Location
Sydney, Australia
Programming Experience
10+
If you would like to learn as much as possible and make it work as much like a professional application as possible, use a database. If you just want to get it done as quickly as possible you could just use arrays (or more probably SortedList and ArrayList objects). It also depends how much information a recipe record is supposed to contain and how much you might want to expand on the program. A database is more flexible and scalable and makes dealing with complex records and relationships easier, but will take more time to initially set up and may make the programming concepts more difficult to understand. Either way, the general concepts are the same:
  • You have a list of recipe records, each containing various fields including a list of ingredients.
  • The user selects the desired ingredients and initiates a search, whereupon your program searches the list of recipes for records where the list of ingredients includes any of those selected and returns the matching records.
If you would like more specific help I'd be happy to provide it once I know whether you will be using a database or local objects.
 

JTDancer48

New member
Joined
May 4, 2005
Messages
3
Programming Experience
Beginner
i want to get this done as quick as possible. I kind of understand arrays but i just am having a hard time getting started. If you want to look at the design layout i have so far i can email that to you. Thank you so much for your help. I am making a program that allows you to check what alcohol, mixers, condiments, ect. and then search what drinks you can make.
 
Last edited:

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,321
Location
Sydney, Australia
Programming Experience
10+
Sorry I haven't responded sooner. I don't think I received notification of your last post, or else I deleted it by mistake.

To accomplish what you want done as quickly as possible, I would suggest that you create a SortedList, with the key for each item being the name of the drink and the value being an Array containing each ingredient. To find every drink that contains lemonade and orange juice you would do something like this:
VB.NET:
[color=Green]'Create an empty list for all drinks.[/color]
[color=Blue] Dim[/color] drinkList [color=Blue]As New[/color] SortedList

[color=Green] 'Add the drinks to the list.[/color]
drinkList.Add("Drink1", [color=Blue]New String[/color]() {"Lemonade", "Orange Juice"})
[color=Green]'...[/color]

[color=Green] 'Create an empty list for the matching drinks.[/color]
[color=Blue] Dim[/color] matchingDrinkList [color=Blue]As New[/color] ArrayList

[color=Blue] For[/color] i [color=Blue]As Integer[/color] = 0 [color=Blue]To[/color] drinkList.Count - 1
	[color=Blue]If[/color] drinkList.GetByIndex(i).IndexOf("Lemonade") <> -1 [color=Blue]AndAlso[/color] drinkList.GetByIndex(i).IndexOf("Orange Juice") <> -1 Then
		[color=Green]'This drink contains both ingredients so add it to the list of matches.[/color]
		matchingDrinkList.Add(drinkList.GetKey(i))
	[color=Blue]End If[/color]
[color=Blue] Next[/color]
 
Top Bottom