BrowserHistory.txt.cpp
BrowserHistory.txt.cpp
#include <queue>
#include <string>
#include <regex>
struct Node {
string url;
Node* next;
};
class HistoryTracker {
private:
public:
HistoryTracker() {
top = nullptr;
size = 0;
newNode->url = url;
newNode->next = top;
top = newNode;
size++;
string goBack() {
if (isEmpty()) {
return "";
top = top->next;
delete temp;
size--;
return url;
string goForward() {
if (isEmpty()) {
top = newTop;
delete temp;
size++;
return url;
bool isEmpty() {
int getSize() {
return size;
};
// Main function
int main() {
HistoryTracker historyTracker;
// Read initial URLs from file
ifstream file("C:\\Data\\BrowserHistory.txt");
string url;
if (validateURL(url)) {
historyTracker.addUrl(url);
} else {
cout << "Error: Invalid URL format - " << url << endl;
file.close();
int choice;
while (true) {
string newUrl;
switch (choice) {
case 1:
if (validateURL(newUrl)) {
historyTracker.addUrl(newUrl);
} else {
cout << "Error: Invalid URL format - " << newUrl << endl;
break;
case 2:
if (!historyTracker.isEmpty()) {
} else {
break;
case 3:
if (historyTracker.getSize() > 1) {
} else {
break;
case 4:
default:
break;
return 0;
regex pattern("www\\..+\\..+");