CS127: Data Structures, Fall 2001
Assignment 1: Web Page Navigation with Stacks
Assigned on Wednesday, 9/12/01.
Design document due on paper at the beginning
of class on Friday, 9/14/01.
Final program due electronically on Wednesday, 9/19/01 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.
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. |
Programming Details
This project is intended to help you get some practice with stacks! As
such, please adhere to the following restrictions:
-
Implement the stack code yourself - don't use the stack implementation
in STL.
-
The only mechanism you can use to store web pages is via pushing onto a
stack. Don't "violate" the stack by inserting things into the middle of
an array or a list. Make appropriate use of private members.
-
You can only view what web page is on the top of a stack by using a top()
function. Don't "violate" the stack by looking at what items are below
the top without popping it off first.
-
Assume that the browser starts off in window 1.
Submission details
You should submit the following files, using the hsp program:
-
stack.h
-
stack.cpp
-
minibrowse.cpp
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.
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;