Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "browserhistory.h"
- #include <iostream>
- #include <string>
- BrowserHistory::BrowserHistory(string default_url)
- {
- head = new Node;
- head->url = default_url;
- head->next = nullptr;
- head->prev = nullptr;
- tail, current = head;
- }
- string BrowserHistory::current_url()
- {
- return current->url;
- }
- void BrowserHistory::go_to_url(string url)
- {
- Node* temp = new Node;
- temp->prev = current;
- temp->next = nullptr;
- temp->url = url;
- current->next = temp;
- tail, current = temp;
- }
- void BrowserHistory::back()
- {
- if(current->prev != nullptr)
- current = current->prev;
- }
- bool BrowserHistory::can_go_back()
- {
- if (current->prev != nullptr)
- return true;
- else
- return false;
- }
- int BrowserHistory::past_url_count()
- {
- Node* temp;
- temp = current;
- int count = 0;
- while (temp->prev != nullptr)
- {
- count += 1;
- temp = temp->prev;
- }
- return count;
- }
- void BrowserHistory::forward()
- {
- if (current->next != nullptr)
- current = current->next;
- }
- bool BrowserHistory::can_go_forward()
- {
- if (current->next != nullptr)
- return true;
- else
- return false;
- }
- int BrowserHistory::future_url_count()
- {
- Node* temp;
- temp = current;
- int count = 0;
- while (temp->next != nullptr)
- {
- count += 1;
- temp = temp->next;
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement