Hello, I am getting back into programming after many years off the grid.
I am a cook and I want to make a program that stores and retrieves food pairings.
I am wondering what a good data structure to use would be? Arrays seem to be limited by their static size although if I am reading and writing from a text file maybe I can create them and destroy them as needed? I have some experience using struct. I have no experience using linked lists, hash tables or anything like that but they seem interesting. I started taking some online courses but there is so much irrelevant information involved that it makes my head spin and most of them don't relate to saving and retrieving information effectively.
For example I would like to store under
APPLE: caramel, ginger, cinnamon, cloves, nutmeg etc.
and be able to add or eventually subtract items at any time.
My best bet would be making a class to hold and return all the information you need. Inside the class you could have structs for each ingredient, for instance here apple, and within it, a vector of strings to hold the names of other ingredients you want paired with it. You could of course add and delete items from said struct but you would have to read from a file when you run the program and save to the file every time you change anything.
That's probably how I would go about doing what you said. I hope that helps :)
<maps> are ideal. In fact they are colloquially known as 'dictionaries'. It might even be simply a matter of storing a single string against the key rather than using a <vector>, whatever.
( Something tells me the dutch-apple on the menu might be rather more palatable than the orange, despite the dutch connection there. )
need a solid working define for what a food pairing means. I know what it means in english, but not what YOU mean by it in terms of your program design.
It sounds like you need something capable of a many to many relationship. What sort of info do you want back? do you want to know that apples pair with pork which pairs with bbq sauce and onions, and get feedback that apples and bbq sauce is a no-go? or it it simpler, like red wine and a steak?
And, does chef have 100000000000000 ingredients where you can select up to 1000 of them to form a dish and need to know if the dish is tasty? (This isnt aimed at your question, its just a running forum joke about a low quality code competition site).
I was thinking (the worst perhaps) and it was some sort of methamphetamine concoction in which case your suspicions about the cook thing were well founded :(
Thank you for the tips! I am definitely looking into vectors and maps.
It sounds like you need something capable of a many to many relationship. What sort of info do you want back? do you want to know that apples pair with pork which pairs with bbq sauce and onions, and get feedback that apples and bbq sauce is a no-go? or it it simpler, like red wine and a steak?
Eventually I would like to incorporate more complex relationships like what you suggest. For now I just want to be able to search a database of foods and their pairings. I was stuck wondering what data type would be best for being able to add and subtract entities from each entry. If you have input on how to cross reference later I would take it so I can start thinking about it. Eventually I want to incorporate nutritional information and have a program that helps people make decisions on what the eat based on nutrition, taste and user preferences. I am using the idea to learn the language so I know I will probably have to start from scratch several times as I advance but I want to take it step by step and learn the concepts as I go along.
I ordered a more up to date book to work out of since the one I have is old and has nothing to say about vectors or maps.
is possibly not to a lot of people's taste which is why we don't hear of it often. Well certainly in my area. Is it usually served hot, warm or cold, may I ask?
namespace spicy_food_tips
{
/*
If the chilli you've just eaten is so f'kin hot you
can't take the heat any longer, don't drink water,
drink milk because the capsaican in chilli reacts
with the casein in milk to destroy the heat.
*/
}
Is it usually served hot, warm or cold, may I ask?
Muy caliente.
Paradoxically, used topically capsaicin aids in controlling peripheral nerve pain.
Casein (from Latin caseus "cheese") are proteins commonly found in mammalian milk, comprising about 80% of the proteins in cow's milk but only between 20% and 45% of the proteins in human milk. So choose your udder wisely.