Reference no: EM133694192
Data Structures
Purpose
To measure the student's ability to implement and/or use a linked list structure to solve an underlying problem in C++.
Overview
This assignment will test your ability to implement and use a linked list data structure to implement a (simulated) web browser. This browser will allow users to visit and navigate a history of websites visited, along with maintain a list of bookmarked favourite sites, using a linked list.
You will be provided with a main program that includes a menu and prompt to control and test your implementation. Additionally, the main program will be able to run a list of commands from a file. You will also be provided with appropriate header files and a makefile, leaving you to implement only the Node, LinkedList, and Browser classes.
The Supplied Files
This section gives an overview of the files that you are provided as part of this assignment. There are quite a few, so you are recommended to take some time to understand the overall structure of the program.
main.cpp - contains the main function and other functions that allow you to interactively test the functions you implement in playlist. This file should not be modified.
node.h - contains the header for the Node class, which includes the instance variables and behaviours that your node should contain. This file should not be modified.
node.hpp - contains (skeleton) template implementations for the Node class. This is where your implementation of the node is to be completed. This file should be modified and be part of your submission.
linked_list.h - contains the header for the LinkedList class, which includes the instance variables and behaviours that your linked list should contain. This file should not be modified.
linked_list.hpp - contains (skeleton) template implementations for the LinkedList class. This is where your implementation of the linked list is to be completed. This file should be modified and be part of your submission.
browser.h - contains the header for the Browser class, which includes the instance variables and behaviours that your browser should contain. This file should not be modified.
browser.cpp - contains (skeleton) implementations for the Browser class. This is where your implementation of the browser is to be completed. This file should be modified and be part of your submission.
makefile - the makefile for the project, which outlines the build recipe. The -g flag is set for you to make debugging and/or memory leak detection more convenient, should you wish to use these tools. This file should not be modified.
TestCommands.txt - a text file containing a sequence of commands that can be used to run the program in file mode. This is simply a text file with valid commands, one per line. This file is not really part of the program so you may modify if you wish.
Running the Program
Of course, you will need to ensure the program is compiled prior to running it. You can use the supplied makefile for this - it will produce an executable called Browser.
Note: while the initial code you have been supplied will compile, it will produce a compiler warning (see Figure 1). In this case, the warning is indicating that we have a method expecting a reference to be returned, but we have not returned anything. In fact, all the methods you are meant to implement are either empty or return default values - you are provided only with a skeleton of the final program and are expected to complete the required implementations.
The program will operate in two different modes: prompt (interactive) mode and file mode, each described below. In prompt mode, the user is presented with a prompt to enter commands in sequence. In file mode, the user can supply a text file, which contains a list of commands that will be executed - this can be used to test a particular sequence of commands without having to type them every time.
Important Notes: The program does not validate web addresses. The program is also not equipped to handle spaces in the web address provided. Rather, the program interprets spaces as the separator character between different command arguments. If you wish to supply your own data, ensure that you do not include spaces in web addresses.
Prompt (Interactive) Mode
To run in prompt mode, the program should be executed as normal using the command:
./Browser
When the program is first run, you will be presented with a welcome message and a prompt. The prompt will allow you to enter commands to interact with your browser. Initially, the program will run, but not successfully given that you will not have implemented the functionality. However, you are recommended to have a look through the code, particularly the header files, to better understand the requirements for the various methods you must write.
Figure 2 shows the list of commands that the program can interpret and execute. The parsing and execution of these commands is handled in the main file. Thus, your concern is only to implement the underlying functionality to provide the intended behaviour.
Figure 3 shows an example of the program operating in prompt mode, where the user has entered the commands listed after the prompts Enter Command:.
File Mode
To run in file mode, the program will be executed with an argument containing the name of the file. To run in file mode, the program will be executed as:
./Browser TestCommands.txt
The list of commands in the supplied TestCommands.txt is minimal and does not run an exhaustive set of tests. However, you may supply the path to any text file as the argument. In fact, you are encouraged to develop your own set of tests, which may be easiest to do with a preset list of commands in a text file.
Note: Executing the program in file mode should produce the exact same output as running the corresponding commands, in sequence, in prompt mode.
Figure 4 shows an example of the program operating in file mode, where the user has supplied the default TestCommands.txt file. Note: this figure does not show the entirety of the output, only a sample.
The Tasks
Your tasks can be summarised as the implementation of three classes, namely Node, LinkedList, and Browser. For each class, you are provided with the header file and skeleton implementations (i.e., method stubs that allow the program to compile, but are otherwise non-
functional). You are not permitted to change the supplied header files and must implement all methods listed in the header files, irrespective of whether they are used in the program.
Node
The Node class is a templated version of a node object and should be implemented as discussed in the lectures. For a full list of methods required and some important details, you should examine the node.h file and its associated documentation.
LinkedList
The LinkedList class is a templated version of a doubly linked list using two sentinel nodes and should be implemented as discussed in the lectures. For a full list of methods required and some important details, you should examine the linked_list.h file and its associated documentation.
Browser
The Browser class contains the main logic of the browser and uses your LinkedList class to supply the underlying functionality. That is, this class must use the public interface provided by your LinkedList class to perform the various operations that support the list of commands given in Figure 2. You are not permitted to use std::list or any other collection in the std namespace. For a full list of methods required and some important details, you should examine the browser.h file and its associated documentation.
Marking
As mentioned previously, this assignment is worth 100 marks and accounts for 15% of your final grade. Late submissions are subject to the rules specified in the Course Outline.
Your submission will be assessed on both correctness and quality. This means, in addition to providing a correct solution, you are expected to provide readable code with appropriate commenting, formatting, best practices, memory management, etc. Code that fails to compile will result in a zero for the functionality correctness section. Your code may be tested on functionality not explicitly shown in the supplied demo file (i.e., using a different main.cpp file). Hence, you are encouraged to test broader functionality of your program before submission.