hi guys
i'm sorry about the thread i've posted yesterday. that was obviously the wrong one. this is the correct one.
Code:
#include <iostream>
#include <windows.h>
#include <conio>
#include <string>
#include <vector>
#include "tokenizer.h"
using namespace std;
void end();
void mainmenu();
void mainmenu()
{
HANDLE hOut;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTitle("TESCAGEN version 1.0");
cout<<"\n-------------------------------------------------------------------------------";
cout<<"\n\t *** TESCAGEN: BB vs WB *** ";
cout<<"\n-------------------------------------------------------------------------------\n";
cout<<"\n\n[S] - Start Program\n";
cout<<"[Q] - Quit Program\n";
}
void main()
{
char menu;
ifstream infile;
do
{
clrscr();
//SetConsoleTextAttribute(hOut, BACKGROUND_BLUE | BACKGROUND_INTENSITY);
//SetConsoleTextAttribute(hOut, BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
mainmenu();
cout<<"\n\nSelect an option: ";
cin>>menu;
if(isalpha(menu))
switch(menu)
{
case 'S':
case 's':
infile.open("ass.txt");
string line;
vector <string> tokens;
bool endOfFile = infile.eof();
int count =0;
vector <string> ident;
ident.push_back("if(x<5||x>20)");
ident.push_back("if(i==1||i==x)");
ident.push_back("else if(j==1||j==x)");
ident.push_back("else if(j==i)");
ident.push_back("while(x!=20)");
vector <string> test;
test.push_back("Possible test cases: x>5, x==5, x!=5, x<20, x==20, x!=20");
test.push_back("Possible test cases: i<1, i>1, i!=1, i<x, i>x, i!=x");
test.push_back("Possible test cases: j<1, j>1, j!=1, j<x, j>x, j!=x");
test.push_back("Possible test cases: j<i, j>i, j!=i");
test.push_back("Possible test cases: x<20, x>20, x==20");
while(!endOfFile)
{
endOfFile = getStringAndTokens(infile, line, tokens);
if(!endOfFile)
{
count++;
cout<<count<<")"<<line<<endl<<endl;
if(!ident.empty())
{
for(int i=0; i<tokens.size(); i++)
{
for(int d=0; d<ident.size(); d++)
{
for(int c=0; c<test.size(); c++)
{
if(tokens[i] != ident[d])
{
ident.push_back(tokens[i]);
}
else if(ident[d]==test[c])
{
ident.push_back(test[c]);
}
}
}
}
}
for(int i=0;i<tokens.size();i++) {
cout<<tokens[i]<<endl;
}
cout<<"\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n"<<endl;
ifstream(infile);
system("Pause");
}
}
getch();
break;
} else
cout<<"\t\t Wrong key in. Please try again.\n\n";
}while(menu!='q'&& menu!='Q');
end();
}
void end()
{
clrscr();
cout<<"\n\n\n\n\n\n\n\n\t\t\t Thank you for using this program!";
cout<<"\n\n\n\t\t\t Coded by: Aizatul Afzan bt. Ibrahim\n";
cout<<"\t\t\t Email: [email protected]";
getch();
exit(0);
}
i'm trying to output the test cases when it a particular identifiers encountered. is this the correct way?
Code:
if(!ident.empty())
{
for(int i=0; i<tokens.size(); i++)
{
for(int d=0; d<ident.size(); d++)
{
for(int c=0; c<test.size(); c++)
{
if(tokens[i] != ident[d])
{
ident.push_back(tokens[i]);
}
else if(ident[d]==test[c])
{
ident.push_back(test[c]);
}
}
}
}
}