Question: I'm having trouble figuring out how to go about programming the following. Any help would be appreciated. Overview In this lab you will create an

I'm having trouble figuring out how to go about programming the following. Any help would be appreciated.

Overview

In this lab you will create an implementation of a List and then use your implementation to simulate a web browser's basic functionality.

List Interface

#ifndef LIST_INTERFACE_H #define LIST_INTERFACE_H #include  template  class ListInterface { public: virtual ~ListInterface(){} virtual bool isEmpty() const = 0; virtual int getLength() const = 0; virtual void insert(int position, T entry) throw (std::runtime_error) = 0; virtual void remove(int position) throw (std::runtime_error) = 0; virtual void clear() = 0; virtual T getEntry(int position) const throw (std::runtime_error) = 0; /** Here's an example of a doxygen comment block. Do this for all methods * @pre The position is between 1 and the list's length * @post The entry at the given position is replaced with the new entry * @param position: 1<= position <= length * @param newEntry: A new entry to put in the list * @throw std::runtime_error if the position is invalid. **/ virtual void replace(int position, T newEntry) throw (std::runtime_error) = 0; }; #endif 

Notes on the interface:

All methods (minus the destructor) are pure virtual because your LinkedList class will inherit from this interface and provide definitions

Again, your LinkedList class will need to inherit from this interface

There are no member variables in the List Interface since those are always tied to implementation details.

The destructor can be virtual, but cannot be pure virtual so we leave an empty definition

Web Browser Simulator

You will create a program that mimics the behavior of your web browser. Since this in only a one week lab, browser won't have multiple tabs. You could think of it as a modern day browser without only one tab open.

Here is an interface for the WebBrowser. You may not change or add to this interface. You must implement this interface, satisfying all the requirements described.

Reminder Constructors and assignment overloading are allowed to be added to your WebBrowser classes, since they do not alter the interface's intended behavior.

Your implementation can then be used by an Executive class.

#include "ListInterface.h" #include  class WebBrowserInterface { public: /** * @post All memory allocated by the implementing class should be freed. * This, as with all virtual destrucors, is an empty definition since we * have no knowledge of specific implementation details. */ virtual ~WebBrowserInterface(){} /** * @pre none * @post the browser navigate to the given url * @param url, a string representing a URL */ virtual void navigateTo(std::string url) = 0; /** * @pre none * @post if possible, the browser navigates forward in the history otherwise it keeps focus * on the current URL */ virtual void forward() = 0; /** * @pre none * @post if possible, the browser navigates backwards in the history otherwise it keeps focus * on the current URL */ virtual void back() = 0; /** * @return the current URL */ virtual std::string currentURL() const = 0; /** * @pre The list being passed in is empty * @post The current browser history is copied into the given list * @param destination, an empty list of strings that will have a copy of current history copied into */ virtual void copyCurrentHistory(ListInterface& destination) = 0; }; 

Reading the history from file

Command to interact with your browser will come from a file. The file name will come in on the command line.

Browser Command Description
NAVIGATE Navigates the browser to the given URL. NOTE navigating to a URL retains all URLs accessible from going BACK, but any URLs that would have accessible from going FORWARD are now lost
BACK A command indicating the web browser is redirected to the previous URL in the history. If there is no URL further back, then the browser stays on the current URL.
FORWARD A command indicating the web browser is redirected to the next URL in the history. If there is no URL that is next, then the browser stays on the current URL.
HISTORY Prints the current URL history to the screen using the following format:
Oldest ===========   <==current (assuming this is the current URL)  =========== Newest 

Sample input file

NAVIGATE http://google.com NAVIGATE http://reddit.com NAVIGATE http://facebook.com NAVIGATE http://myspace.com BACK BACK HISTORY NAVIGATE http://bing.com HISTORY 

Output to screen:

Oldest =========== http://google.com http://reddit.com <==current http://facebook.com http://myspace.com =========== Newest Oldest =========== http://google.com http://reddit.com http://bing.com <==current =========== Newest 

Libraries You May Include

iostream

fstream

string

stdexcept

Vectors or any other dynamic data structure that you don't build yourself is forbidden!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!