//STACK&QUEUE
#include <iostream>
#include <stack>
#include <queue>
using namespace std;
class WebBrowser
{
private:
stack<string> gobackStack;
queue<string> forwardQueue;
string currentPage;
public:
WebBrowser()
{
currentPage = "";
}
void visitPage(string page)
{
if(![Link]())
{
[Link](currentPage);
}
currentPage = page;
while(![Link]())
{
[Link](currentPage);
}
}
void gotoPreviousPage()
{
if(![Link]())
{
[Link](currentPage);
currentPage = [Link]();
[Link]();
}
else{
cout << "\nCannot Go Back to Previous Page. No more pages available.\
n";
}
}
void gotoNextPage()
{
if(![Link]())
{
[Link](currentPage);
currentPage = [Link]();
[Link]();
}
else{
cout << "\nCannot Next Page. No more pages available.\n";
}
}
void displayBrowsingHistory()
{
cout << "\nBrowsing History:\n";
stack<string> browsingHistory = gobackStack;
while(![Link]())
{
cout << [Link]() << endl;
[Link]();
}
}
void clearBrowsingHistory()
{
if([Link]() && [Link]())
{
cout << "\nThere's nothing to clear.\nNo Browsing History.......\n";
}
else{
while(![Link]())
{
[Link]();
}
while(![Link]())
{
[Link]();
}
}
}
void displayCurrentPage()
{
if(![Link]())
{
cout << "\nCurrent Page: " << currentPage << endl;
}
else{
cout << "\nNo visited Pages available.\n";
}
}
void displayMenu()
{
cout << "\n---------------WEB BROWSER----------------\n";
displayCurrentPage();
cout << "\n1. Visit New Page\n2. Go to Previous Page\n3. Go to Next Page\
n4. View Browsing History\n5. Clear Browsing History\n6. Exit Browser\n";
}
void runBrowser()
{
int choice;
string URL;
bool condi = true;
while(condi){
displayMenu();
cout << "\nEnter Choice (1-6): ";
cin >> choice;
[Link]();
switch(choice)
{
case 1:
cout << "\nEnter URL or Page Name: ";
getline(cin, URL);
visitPage(URL);
break;
case 2:
gotoPreviousPage();
break;
case 3:
gotoNextPage();
break;
case 4:
displayBrowsingHistory();
break;
case 5:
clearBrowsingHistory();
break;
case 6:
cout << "\nLeaving Browser..........\nGoodbye........\n";
condi = false;
break;
default:
cout << "\nInvalid Input. Enter number from 1-6.\n";
}
}
}
};
int main()
{
WebBrowser browser;
[Link]();
return 0;
}