cout<<"How many letters do you want to play with?"<<endl;
cin>>x;
cout<<"where do you want to move player?"<<endl;
cin>>line3;
while(text.good())
{
getline(text,line);
if(line.length() == x)
{
G.addVertex(line);
int diff = G.oneCharDiff(line3,line,x);
if (diff == 1)
{
G.addEdge(line3,line);
}
}
}
G.movePlayer(line3); //moves to vertex
cout<<"you are at...."<<G.getPlayerLocation()<<endl; //outputs what vertex you're currently at
G.getExits(); //output what vertexes are connected through edges
How many letters do you want to play with?
3
where do you want to move player?
cat
you are at....cat
caw
cay
cit
cot
cut
eat
fat
gat
hat
kat
lat
mat
nat
oat
pat
qat
rat
sat
tat
vat
wat
Press any key to continue . . .
Okay here I have a code that will input a text file. It's a dictionary text file so there's line after line of text. I can input all the x letter words into the graph, but the assignment is to connect all the vertices in the graph that have only 1 letter difference. I am aware what I have doesn't do that, it only does it for one user defined string. This was just a test to see if the program was functioning, specifically the onecharDiff function. Now i have to go through the graph compare each vertex and connect the 1 character difference strings. ("dog" and "dig", "sit" and "sat", etc.)
Any idea how I can do this?
woops. just realized this is flawed too. it doesn't include "bat" or any 1 character difference strings BEFORE the input. however i don't know if this will be an issue seeing as how it's a test code to test the onecharDiff function.