I have a project that requires me to make a search engine for classes. If i were to enter Biology, then classes such as genetics, chemistry, anatomy and physiology are to show up. But the thing is i have the classes and their descriptions in a file and i was wondering if anyone can give me some pointers on how to atleast start the project. I really don't know how to group the classes together so that I can compare the words and come up with results....or is there a better way?

Recommended Answers

All 7 Replies

It might be a good idea to create a class or struct of type schoolCourse or something like that which has one or more of some type of variable to keep track of what category it is in (e.g. language, biology, science) and break it up as much or as little as you need to with those classifications/keywords, which can be integers, enumerated types, etc. or strings (which would be playing it a little bit looser since they don't compare as nicely). It should also have a string to hold the class name and any other information you need to know about the class.

Fill an array of type schoolCourse with the information for each of your available classes.

Then, when the user inputs the search key, just go through the array of schoolCourses and compare the search key with the keyword/classification.

But if i already have the list of classes in a file is there a way i can compare the descriptions of the classes by reading that file from the program?

But if i already have the list of classes in a file is there a way i can compare the descriptions of the classes by reading that file from the program?

Sure, you can compare the search key entered by the user to values contained in the file, but you have to read them in from the file and store them somewhere useful for the program. The values have to be somewhere that the program can get at them to compare the values, and the class/struct I described above is a fairly clean and straightforward way of doing that.

What all information is contained in your list of classes file? Is it just the class name, or is there other information about the class as well, like categories (e.g. you have classes named biology and chemistry, both might have a category of science). If that kind of information is present, it should be a pretty simple comparison from the search category to the class category. If not, you will need to have a pretty exhaustive comparison function hard-coded in that takes the search key entered by the user and compares it to some finite set of possible class names that might match.

yeah it has the class name and the description of the class we have to make it to where if i put in biology, the description of biology will appear. then it finds matches. let's say the matches were chem and anatomy: it would bring up both classes along with their descriptions but the descriptions are in a text file i believe

yeah it has the class name and the description of the class we have to make it to where if i put in biology, the description of biology will appear. then it finds matches. let's say the matches were chem and anatomy: it would bring up both classes along with their descriptions but the descriptions are in a text file i believe

Ok. You should create a struct or class (a c++ class, an object, that is) that has variables for each piece of data that you know about a class (a school class, or course, that is). Build an array of these objects and populate it with the information for each of the classes that you know about, the data for which is stored in your text file.

Then, when the user inputs the class (school) they want to search on, find that class (school/c++) in the array and display the elements from it. Then go through the rest of the array and find other classes (school/c++) which have the same category and display them.

I understand to a certain extent i am a beginner at c++ and i was wondering if you could give an example code for me if you can that would be great thanks

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.