CS127: Data Structures

Assignment 3: Web Page Navigation with Stacks

Assigned on Monday, 1/14/02.
Design document due on paper at the beginning of class on Wednesday, 1/16/02.
Final program due electronically on Monday, 1/21/02 at 5 PM.

Overview

This project will be your chance to write a new web browser to take the market by storm! You'll write Minibrowse, a small part of a web browser. Specifically, you will write the navigation piece, which handles the "back" and "forward" buttons as well as keeps track of which web pages the user is viewing. Furthermore, this will be a Multi-Document Interface (MDI): the user can have up to thirty browser windows open simultaneously, and switch back and forth between them.

Using text commands to navigate in Minibrowse

All input to the browser will be via standard input. If a user enters minibrowse at a UNIX prompt, then the user should be able to enter commands at the keyboard. Alternatively, the user can have the commands already present in a flat file, and enter minibrowse < filename at the UNIX prompt to process all the commands at once. All output should be directed to standard output.

It is important that your program work both interactively and via redirecting standard input.

Minibrowse can accept the following commands. After every command, it should display the full URL for the web page which would be showing in the browser window if we had implemented a full-fledged browser.

Commands:
 
Command: Description Output
Web page location (i.e. http://www.mathcs.carleton.edu) Navigate to the indicated web page Display the new web page URL.
back Navigate back one page Display the appropriate URL. If none available, indicate accordingly.
forward Navigate forward one page Display the appropriate URL. If none available, indicate accordingly.
integer from 1 through 30 Switch to window with ID number as indicated Display the current URL in the new window.
exit Exit minibrowse  

Programming Details

This project is intended to help you get some practice with stacks! As such, please adhere to the following restrictions:

You should make your program as robust as possible. If the user enters something that is not one of the standard commands, you may assume that it is a web page application. However, if the user does not say "exit" and you are redirecting standard input from a file, your program should handle this gracefully (e.g., it does not go into an infinite loop).

Submission details

You should submit the following files, using the hsp program:

Sample session with Minibrowse

Here is a sample session with Minibrowse. I've indicated the user input in bold, and the response in italics.

http://www.mathcs.carleton.edu
http://www.mathcs.carleton.edu
http://www.yahoo.com
http://www.yahoo.com
http://www.lycos.com
http://www.lycos.com
back
http://www.yahoo.com
back
http://www.mathcs.carleton.edu
forward
http://www.yahoo.com
forward
http://www.lycos.com
forward
No page found.
2
New window.
http://www.palmgear.com/support
http://www.palmgear.com/support
http://www.hotbot.com
http://www.hotbot.com
http://www.deja.com
http://www.deja.com
back
http://www.hotbot.com
1
http://www.lycos.com
back
http://www.yahoo.com
http://www.slashdot.com
http://www.slashdot.com
forward
No page found.
back
http://www.yahoo.com
back
http://www.mathcs.carleton.edu
back
No page found.

exit

Frequently Asked Question

Q: How can I convert a string to an integer?
A: Use the method c_str to convert the string to a C-string, then use the function atoi to convert to an integer. For example:

  string x = "21234";
  int y = atoi(x.c_str());
  cout << y << endl;