the types are up to you. here is an example..
Code:
// in routes.h (or whatever)
class Routes
{
// you can use c-strings or whatever you like using
string locA, locB, route;
public:
......
void setLocationOne(string location);
void setLocationTwo(string location);
void setRoute(string route);
string getLocationOne();
string getLocationTwo();
string getRoute();
};
// in Routes.cpp -------------------------------------------------------------
void Routes::setLocationOne(string location)
{
locA = location;
}
//.... and so on
string Routes::getLocationOne()
{
return locA;
}
//...... and so on
// data.txt ----------------------------------------------------------------------
math building
science building
The best route between..... is to go this way ......
math building
study hall
the route from......
science building
study hall
go this way....
// initiallizing in main code. (pseudo-code) --------------------------------
Routes r[number of records]; // actuall number or else dynamic allocation
for(index = 0; .... number of records)
{
r[index].setLocationOne(cin.getFirstLine());
r[index].setLocationTwo(cin.getSecondLine());
r[index].setRoute(cin.getThirdLine());
}
// out put dialogue, get users desired locations.
string userLoc1, userLoc2;
for( number of records)
{
// note the '==' is just pseudo for comparing, actually use compare functions (ie. strcmp() )
if ( (userLoc1 == r[index].getLocationOne() && userLoc2 ==
r[index].getLocationTwo() ) || (the oppisites match ) )
{
cout << "The best route is " << r[index].getRoute();
break;
}
}
i hope that helps, just lemmie know if you have anymore questions.... perhaps post some code.